The headphone jacks on iPhones and iPods automatically sense when you connect a pair of headphones. With headphones in, the devices mute the speaker, playing only through the headphones. After removing the headphones, the device should re-enable the speaker. Sometimes, however, lint or debris will build up inside the connector, causing the device to think the headphones are still attached. This leaves the speaker unusable. Trying a few cleaning methods may fix the problem, disabling the headphone output properly.
Spray a blast of compressed air from a can into the headphone jack. If possible, use a can that includes a narrow nozzle to better aim the air.
Video of the Day
Cut the tip off a cotton swab, leaving only a small amount of cotton on the stick. Rub the swab around the inside of the jack to try to pull out debris.
Straighten out a paper clip and wrap tape tightly around one end of it, sticky side out. Attach the tape to the clip with another small piece of tape to keep it in place. Put the paper clip into the headphone jack and rub it around to stick any dirt onto the tape.
Dip the cut cotton swab into a small amount of isopropyl rubbing alcohol, then rub out the inside of the headphone jack with it. Rubbing alcohol helps clean corrosion from contact points, which may be the culprit if simple dirt removal doesn't help.
Insert your headphones, pressing the plug in tightly and rotating it. Pull the plug back out and check if the iPhone now has disabled headphone mode.
Take your iPhone in to an Apple store for repair if no other methods resolve the problem.