I sometimes get that- figgered out all I was doing was hitting the volume buttons on the side. If it is not this, or what sparky posted, you may want to take it in to an Apple store...
I havent been accidentally touching the silent/ring button, so I guess there's something wrong with my phone, but i jailbroke it, so i dont know if apple will by willing to take it back. it's kinda annoying, but i can live with it.
That happens to me once in a while. For a while, I thought the silent/ring button was going bad, but now I think its just a software glitch. Whenever it happens over and over, I reboot, then it goes away.