It helps to be connected to a call while doing this (I simply connected to my voicemail) so you can watch the headset icon in the lower left corner while inserting/removing the headset. When the icon switches back to the regular 'phone' icon, you're done.

After you do this, you can use headphones/headsets as much as you'd like and it shouldn't get stuck in headset mode ever again. I did this months ago and have been rampantly using headphones since then and have had no problems. And before that, the only thing that could release it from headset mode was the ghastly headset app (Q-tip with alcohol and compressed air stopped working).

P.S. All the graphite powder does is safely lube the inside of the headset jack. There is a bit inside that gets stuck, making the phone think there is a headset plugged in when there isn't. You can find graphite powder in the section of the store where they make keys, as it is commonly used to lube jammed locks.

[EDIT]: The user, jccjmml7 states in the comments below that you may try silicon lubricant as well, though I have never tested this method and can give no feedback on it's effectiveness/safety.

I would think a silicone lubricant (for electrical applications) would be better. Graphite is conductive.

Hmm, interesting thought. I've had no problems with the graphite yet though and have heard no problems from others. Plus, with the silicone lubricant costing around 10-16 times as much as the graphite, I gotta go with graphite for now.

I posted a fix about a week ago and found that (IMO) the cause of the headset issue is the little contacts in the headphone jack are outta wack. The contacts that touch the board are barely touching. When I took mine apart and popped the headphone jack out the two bottom contact were slightly lower than the top two. I just rasied all four to and even above 'normal' height. Popped it back in and no issues since. My phones music app use to pause when opening/closing the slider...gone. Calls going into headset mode...gone.

I posted a fix about a week ago and found that (IMO) the cause of the headset issue is the little contacts in the headphone jack are outta wack. The contacts that touch the board are barely touching. When I took mine apart and popped the headphone jack out the two bottom contact were slightly lower than the top two. I just rasied all four to and even above 'normal' height. Popped it back in and no issues since. My phones music app use to pause when opening/closing the slider...gone. Calls going into headset mode...gone.

Indeed a more difficult, dangerous and time consuming way to go about fixing the problem, but a fix nonetheless! Thank you for the input!

Just used the technique from that Youtube link and it seems to have finally fixed my issue.
At first when I put the shavings from a pencil (graphite only of course) in there it wouldn't go into headset mode at all, I then blew it out with compressed air and just put a little alcohol on the jack, twisted around and it works perfect! (free fixes are good fixes )
The "ghastly app" only solved my problem for one phone call then would always switch back to headset mode.
Thank you for this information! Wish I knew this trick long ago..

I would think a silicone lubricant (for electrical applications) would be better. Graphite is conductive.

I'm with you. However graphite per Wiki is only conductive in non-powdered form - however this is marked as dubious and I personally do not think they are right. There are numerous examples of graphite being added to glues and cements to make conductive paints and conductive glues so I think this is a valid concern.

I should add that I had 'the ghastly headset' app loaded while I added the graphite dust just to monitor things and when I put it in there, media mode and speaker mode kept switching back and forth on it's own. It stopped when I cleaned it out. Strange..