I consider myself tech savy, but I've been doing research on this issue for a few days now. I've come across a number of options. I'll tell you what I've tried (and has worked for others) and what eventually worked for me. Apple tech support didn't list this as a bug and as a result will recommend replacing your phone, this is a last resort option.
Here's the problem, the phone ringer will still work, but you can not control (or hear) sound in itunes, apps, etc using the volume buttons on the side. This is because of one of two reasons. Either you have debris in your headphone jack (less likely) or it's a problem with the ipod dock itself (most common). Here's what I've tried and has apparently worked in other cases.
1. Turn your phone off
2. Take an old (dry) toothbrush and scrub inside the dock connector to remove any lint or dirt.
3. Use a toothpick and pick any additional debris you may find inside.
4. Turn the phone on, hopefully this solved your problem.
If that doesn't work
1. Phone off
2. Strip a qtip and coat it in a tiny bit of alcohol
3. Use it to clean out the headphone jack and the ipod dock/charger connector
4. Turn the phone on, hope it works
This is the solution that worked for me:
Basically the debris in the charger connector is fooling the iphone into thinking it is connected to an iHome type player. This is why there is no sound except for ring tones.
1. With the phone on, plug it into an iHome type player (if you don't have one just use a demo at walmart or something.
2. Let it play as long as possible while it charges
3. Remove it from the player
This fixed the issue for me, but it reverts back to the problem sporatically. The best solution is to have the iphone dock/charger completely replaced. The part is inexpensive online, and most tech savy users can replace it fairly easily. If you don't feel comfortable doing it yourself, contacct a repair store in your area that has iphone experience. They will be cheaper than taking it into an Apple store. (of course if your phone is under warranty, that's another case).
Finally, I've heard if you go to settings>music>sound check; and flip it from on to off and back on, it may help for a little while.
Hope this information helps.