Follow giradman's suggestion to the tee.
If that doesn't work, take it to the Apple store and let them check it. Be sure to perform a complete backup first. I had to have my iPad 2 replaced about 6-7 months after I bought it because the component inside the ipad that detects rotation failed. Apple was good about replacing it (mine was still in warranty, btw) after they satisfied themselves that there was really a problem. So test thorougly before going and if you have to go, just tell them what the problem is and let them do the rest. If yours is still under warranty or you have an active apple care +, you can get a replacement if there is a defect.