I had the same problem. Download the widget "headset blocker" from the market. Just turn it on any time you plug in your headphones or an auxiliary cable. I haven't had the problem happen again since I used this. Found this solution on another forum.
Hope it works for you