It is very common that workers are fired after they give notice that they're leaving a job. It is very unfair when a boss tells workers they have to give 2 weeks notice, then doesn't pay for that time. Usually, there's no law against it.
Employers can say that they "require" 2 weeks' notice before you leave, but for most workers there's no real way they can make you work after you've decided to quit. There are several things to think about when deciding whether to give notice before you leave a job:
Does your boss usually fire people after they give notice? If you are fired when you give notice, then you have some rights to collect unemployment (check your eligibility in "Unemployment Benefits" in the Resource Box on this page. Your boss will argue that you should only be eligible for the period of time you didn't work BEFORE the day you were going to quit. (If you gave 2 weeks' notice and were immediately fired, then there would be one week waiting time before you can collect, and then 1 week of unemployment payment.)
Will you be able to collect your accrued vacation? Some companies have a policy that they will not pay for accrued vacation if you don’t give notice. Check the laws in your state for getting paid accrued benefit time at "Getting Paid When You Leave a Job" in the Resource Box on this page.
Will you ever need a reference from your boss? Leaving without giving notice could mean that you don’t get a good reference. If you give notice, ask for a reference letter that says that you are eligible to be rehired. Ask their policy of what they will say when asked for a reference. (Some employers will only confirm that you worked for them and what dates, for example; that's why a letter is helpful.)
Do you have an employment contract that states rules about giving notice and/or getting paid for the time? If you have an employment contract, check what it says and what happens if you don't comply.
The basic idea is that most workers are "at will," so they can be fired at any time and for any reason (except for legally-protected reasons) -- including for saying that they're going to quit. Good bosses who ask for notice will either let you work or pay you for the time.