OK - I had this same experience on my 4s when I upgraded the OS. Unbelievably frustrating. I resisted upgrading to iOS7 for this exact reason - fear of changes and glitches. I spent over 3 hours on Apple chat support and did everything they suggested:
-check mute button (duh!)
-turn off and on
-hard reset
-compressed air in earphone jack and the 30 pin port
-reset settings
-restored phone
-erased and set up as new and then reloaded all apps/contacts/content etc.
-I also tried evey setting on the phone having to do with volume
None of this worked. In the end they told me it is probably a hardware issue and said I should take it in as it was still under warranty. I mentioned that this appears to be a common issue that is being discussed on the internet - I got a "no comment." Plus I find it hard to believe it is a hardware issue that coincidently occured at the same time I upgraded my OS.
Bottom line - the phone acts like it was docked - Phone rings, alarm works. Everything else was silent and would only work via head phones or on a speaker dock. Volume bar did not exsist and volume buttons did not work when not plugged into earphone or speaker dock. I was at my whits' end. I read a trick somewhere and tried it and it eventually worked.
Basically I repeatedly "undocked" my phone while adjusting the volume. So with my headphones plugged in I would start adjusting the volume with the side volume buttons. This would cause the volume bar to appear and while adjusting the volume I would slowly unplug my earphones (and repeat). The 1st few times the volume bar would "stay" on the screen and I would get audio from my speakers on my phone from a song or audiobook for a few seconds. After 5-10 attempts the phone stayed "undocked" and all speaker function returned to normal and the volume buttons work.
I somehow tricked the phone to either undock or stop what ever loop it was stuck in.
Good Luck, I can't believe it worked. Obviously I was frustrated enough to try anything.