A little while ago, my iPhone stopped responding to headset clicks, and the microphone stopped working. At first, I figured it was due to the headphones themselves — Apple have quite a rep for producing shitty headphones. So I bought some new ones, but these didn’t work either.
I tested with another iPhone, and they worked there, so I decided to take the phone to the shop to have it fixed. Just before I did, I decided to do a quick web search, just in case something turned up. And, lo and behold, something did turn up. As it turns out, the headphone jack apparently has a habit of collecting dust and dirt, and once they get to a substantial amount, some functions stop working.
The fix: turn off the phone, take a paperclip or other thin object, and clean it. This should do the trick.