While the problem isn't particularly common, Web forums are devoted to a mysterious malfunction with the iPhone's headphone jack that causes the phone to get stuck in "headphone mode." When this happens, the iPhone believes that headphones are plugged in even though they have been removed.
Because the problem is relatively uncommon, Apple does not address this issue. However, users have come to several conclusions about what may cause the iPhone to think headphones remain in the jack. In some instances, the iPhone may have dirt or debris that targets the headphone sensor. In other cases, the iPhone's internal wiring may have come loose, melted or been disturbed in a way that causes this malfunction. Finally, it is possible that the software experienced a glitch and simply needs to be reset. If the circuitry is broken, there is little you can do but send it away to be fixed. If it is one of the other causes, though, you should be able to fix it yourself.
If the headphone jack has lint, grime, dried liquids or other debris lodged inside -- even a small amount -- it may think headphones are still present. To clean the headphone jack, spray compressed air in short bursts at an angle to the hole. If you spray straight down, you risk forcing the debris further into the jack or lodging it permanently in the hole. Use a needle or the end of a safety pin to dig out anything that might have gotten stuck. Roll a cotton swab between your fingers to make it smaller, lightly moisten it and wipe out any dried liquid or grime.
Insert and Remove
Some iPhone users have successfully taken their iPhones out of headphone mode by inserting and removing their headphones repeatedly. You can use any headphones that are compatible with the iPhone, but the headphones that came with the iPhone are ideal. Plug them fully into the jack and unplug them quickly and repeatedly until the iPhone recognizes that the headphones have been unplugged. This technique does not work for all users.
Reset and Restore
If the headphone problem results from a software malfunction, resetting or restoring the iPhone should fix it. To reset, hold the Sleep/Wake button and the Home button simultaneously until the Apple logo appears, about 10 seconds. If this doesn't work, make sure all your software is updated, not only for iTunes and your iPhone but also for all of your apps. As a last resort, connect your iPhone to your computer, open iTunes, click your iPhone's name in the left column and click the "Restore" button in the middle of the screen. Follow the prompts to complete the process. This will return your phone to factory settings. If this does not work, take your phone to your local Apple Store to discuss your options for repairs.