I had the same problem and tried everything people suggested. I tried the air, tooth brush, I tried the q-tip, I tried the restart and what I found to solve the problem is to go to youtube, and to google videos (watch a video) and click on the dock connector button and make sure it is not on dock connector or apple tv. I found hitting cancel resumed it to allowing volume buttons to work and sounds to return. However, this solution is not permanent as it eventually happens again. I have seen it occur after using headphones, after connecting to USB, after using Apple Remote with apple tv, so I am unsure what would prevent it from doing this, but I found this solution works temporarily. The phone seems to think it's connected to a dock. I keep my phone pristine in a waterproof case. There is no lint, dust, moisture in my phone and it seems to be a software issues.
It seems that as long as a program thinks you are connected by dock the ringer buttons will not work and sound other than phones do not either. Make sure no program thinks you are connected to the dock or apple tv.
So, What I found also is that when I use "remote" for apple TV and if I don't switch back remote to my library the iphone still thinks it's communicating with Apple TV. For that I had to go to remote and go to my library. The buttons and sounds came back, but for how long I am unsure, as I have had this problem before and it returns.
I hope this helps.