When the iPhone detects that headphones are inserted, it enters "headphone mode." This mode diverts audio from the speakers to the headphones, which is fine when headphones are actually in the jack but problematic when they aren't. Debris is a leading cause of "phantom" headphone mode, but other issues, such as software glitches and liquid damage, can also be contributing factors.
The iPhone has one 3.5-mm stereo headphone mini jack. It is located on the top of the phone, opposite the Sleep/Wake button. The device comes with its own set of Apple earbud headphones, which provide controls for changing volume and navigating through songs, as well as a microphone. The controls and microphone do not come separately; they are attached to the headphone wires. The headphone jack is compatible with third-party headphones as well, but other headphones cannot provide this functionality.
Debris and Damage
Some iPhone experts, such as those at Cellfanatic.com, suggest that phantom headphone mode may be caused by debris in the headphone jack, tricking the sensors into thinking a headphone plug is actually there. They recommend inserting and removing the headphone plug several times to remove this debris. This must be done while the phone is unlocked. Compressed air or a moist cotton swab may also help remove debris. Debris does not necessarily have to be solid; it could also be liquid. Liquid can cause permanent damage to the headphone jack, and this damage is not covered by an Apple warranty.
Restart and Reset
Apple's iPhone troubleshooting guide recommends restarting and resetting the iPhone as an initial approach to solving most problems, especially if they are software-related. Pressing the Sleep/Wake button until the red slider appears allows you to turn off the phone. Pressing the Sleep/Wake and Home buttons until the Apple logo appears will reset the phone.
Update and Restore
The iPhone is not immune to software bugs, and Apple regularly releases patches for these known bugs in its software updates. Updates are accessible in iTunes whenever your phone is plugged into your computer. If nothing else helps, restoring the iPhone is a final resort. This process wipes the phone clean and reinstalls the original iOS software, so it will fix any software glitch. You can immediately re-sync anything stored in iTunes, but you lose personal data and preferences. If the restore does not solve the problem, you know that the issue is with your hardware, which requires the attention of an Apple specialist.