I've had the sleep problem about 10 times with two different iPhones since I first got one 4 days ago, always occurring with the iPhone in my pocket.
I got a new iPhone 4 four days ago, and set it up using the information from my original model iPod Touch. All was fine until the next day, the first time I put it in my pocket to go somewhere. When I arrived and tried to use the phone it wouldn't start. I didn't remember the sequence of holding home + sleep so it seemed bricked until I got home, plugged it into my computer, and got it to wake up. It showed 34% charge, even though I'd used it a few hours before and it then had ~70% charge.
It was the day that hurricane Earl was brushing by, and I was worried that it was a humidity issue, similar to the one that made my iPod Touch useless on humid days, with touches on the screen being registered wrong. So I got the one day old iPhone 4 replaced with another iPhone 4, presumably refurbished, at the Apple store.
I set up the replacement iPhone from the backup. Since then it has failed to come out of sleep about 10 times over the past three days. All have occurred with the phone in my pocket, and the problem does not seem related to humidity since the weather has been dry since the hurricane blew by. Although the iPhone has been sleeping on my desk many times, sometimes connected by USB, sometimes not, it has never failed to come out of sleep when outside my pocket. I don't have a rim bumper yet; I ordered one as part of the free program but it is not supposed to arrive for weeks.
To address hypotheses raised by others: No apps have been running and no music has been playing when it went to sleep. I've never used the headphones. I use iTunes on Vista, having upgraded to the new version between the first iPhone and the second. All the songs were synced manually. The 3G reception in our area is nonexistent to terrible. Our WiFi is great, with two signal extenders giving excellent access with few dead spots. Email is set to sync manually only, with no push.
Although this thread is listed as "answered" it is far from "solved". The pattern of the problem occurring only with the iPhone in my pocket seems significant, though others reported different problems, though one could imagine unifying hypotheses such as signal changes. I can imagine the problem as being due to hardware, but one would have to assume that I got two bad phones, but since Apple changes phones by giving you someone else's returned phone I wouldn't exclude hardware as being the cause since it sounds like many people have returned phones due to this coma problem.
So I'm 4 days into getting a new iPhone and I now have a used iPhone that goes into a coma when I take it anywhere. I called 1 800 MYAPPLE today, went through their menu of automated questions, and was then told they were closed. At least I live a mile from an Apple store.