I have this problem a few weeks (months?) and it drives me mad! Unfortunately, all tips and tricks solve *just consequence, not a reason*. In my case, sound switch in headphone mode every time, *when iPhone warm up* a little. And all those tricks, I have read about, work only when iPhone cool down back. Unfortunately, iPhone warms up very often (longer call, internet, GPS, game...), so my *iPhone is everything but phone*, now. I have iPhone more than a year, but it looks like this problem has appeared after upgrading into OS 3.x. But it might be just coincidence. I am going to reclaim iPhone and I am very surprised that there is still no official reaction from Apple to this serious problem.