I just went through this exact problem today. I ordered online a new iPhone 5 from AT&T to upgrade my old iPhone 3. It arrived yesterday afternoon. It became immediately clear that it was defective right out of the box because the ear speaker was not working. On a call the caller could hear me fine. I could not hear them at all -- unless I placed them on speakerphone. Silly me, I was certain that my local corporate AT&T store would simply swap me for a new one. That was not to be. I was very unapologetically told my defective iPhone, which they (AT&T) had just sold me, was Apple's problem, not theirs. With steam coming out of my ears I went home and called Apple Support. They told me the AT&T store lady was wrong and that they should swap it if less than 14 since purchase (it had been one day since delivery). So I called AT&T customer service and they CONFIRMED what Apple said. I then used AT&T online chat to GET THAT IN WRITING before going back to the AT&T store. And for good measure I called AT&T customer service AGAIN to confirm (and secretly recorded the call so I could play it back to the store lady). But this THIRD AT&T person said the store lady was CORRECT and that it was between me and Apple. He got an Apple person on the phone and this SECOND Apple person confirmed that was the policy. The moment it leaves AT&T's hands it is Apple's problem. The Apple rep (he was very nice) walked me through a reset and a restore, none of which worked. And then he explained my options: 1. Take it to an Apple store and, provided they had one of the exact same models in stock, they just might swap me. 2. Send Apple the phone and they would mail me a new one back- assume 7-10 days. 3. For $29 and temporary $750 hold on my card they would Fedex me a new phone and remove the hold when I returned the bad one. 4. Buy an Apple Care Plan for $69 or $99 (depending on features) and they would provide option 3 for free.
I went with option #3 since the closest Apple store is 2 hours roundtrip and there was no guarantee I would get a new phone. Bottom line? NEVER buy a phone from AT&T by phone or online. Only buy it in the store and MAKE CERTAIN it works PERFECTLY before you leave the store. Better yet...go with VERIZON since AT&T customer service SUCKS badly. As you can see from my experience both Apple and AT&T staff were unclear about the defective device return policy.