Randomphil,
Same issue here. It looked like most of the fixes for this problem you see out there were posted by owners of the iphone 3 & earlier, and none of them worked on my 4 -- not to mention, I hadn't put headphones in since the last time I used the onboard speaker. I think the issue was actually fixed with the 4 as I never have had this problem until now, despite using various non-iPhone headphones for months now.
My phone was in my glove box for a few hours during a foggy day, and when I got back to the car, a small amount of condensation appeared on it when I was handling it - probably due to the quick temperature increase from nearly freezing to being in my hands. Now that I've had time to think clearly instead of rushing to my phone, I realize that, yes, this commonly happens with electronics, even if you're not getting them wet, the condensation in the air can quickly soak into your phone - especially during a rapid temperature change - and cause potential issues, although they are usually minor. Need to allow time for the moisture to dry before using the phone.
I saw your comment yesterday and decided to give it a try. About 3 hours in a tightly sealed bag of rice seems to have wicked out all the moisture, and it works fine now.
Thanks!