To rule out issues other than mechanical failure:
-unplug and re-plug headset;
-reset the iPhone by holding down the Home button and the On/Off switch for 5–7 seconds (until the screen returns to the white Apple logo) then release; and
-if the above doesn’t work then go settings: General: Reset: Reset All Settings (Note: this resets all settings under the settings for the phone and safari but doesn’t erase any media or email or accounts).
and the “DEFCON 1” option: connect to iTunes and do a restore (perform a sync first). This does erase everything on the iPhone and you’ll have to re-sync after the Restore! Beware if you have a jailbroken iPhone the restore procedures may be different-perform AT YOUR OWN RISK!