- Try cleaning out/blowing out the headphone jack. Try inserting/removing the plug a dozen times or so. There is a little switch in the headphone jack that disconnects the speaker when the headphone jack is inserted.
Fix for iphone Earphone Bug
Try the following to rule out a software problem
- Reset the iOS device. Nothing will be lost
Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Reset all settings
Go to Settings > General > Reset and tap Reset All Settings.
All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
- Restore from backup
- Restore to factory settings/new iOS device.
- Make an appointment at the Genius Bar of an Apple store. Seems you have a bad headphone jack or other hardware problem
Apple Retail Store - Genius Bar