Basic troubleshooting from the User's Guide is reset, restart, restore (first from new then from backup). Try each of these in order until the issue is resolved.
If after trying all of the above the issue still exists, take the device to Apple for evaluation and possible replacement.
Currently Being ModeratedDec 23, 2012 3:14 AM (in response to diesel vdub)
i havent bought it from the apple store.Got it in exchange for my iphone 4.
The problem still persists.It randomly goes off when im not using the phone.
I have to keep resetting it otherwise i cant access the phone.
Warranty has nothing to do with the owner, it is tied to the device.
If the device is under warranty and has an issue covered under warranty, Apple will replace it.
Regardless, basic troubleshooting must be done first.
Of course, the user can always be stubborn, refuse to do anything and live with the issue.