It sounds like it is most likely stuck in DOCK mode; it thinks something is connected to the dock, and is passing all audio through dock connector which then also abdicated volume control to the accessory rather than on the phone/pod/pad.
This could be the software stuck if it corrects itself after a reboot and a connect to USB to a computer to alert the device that it's no longer supposed to send line-out level sound.
Basically, when you connect an iOS device to a car stereo or other dock, there is some intelligence to determine if the volume should work like headphones where the user can control things or in line mode where the iOS device should send a line-level signal and the car audio is responsible for amplification and volume control.
If reboots and restores do not fix this, you will need to get the hardware cleaned and/or repaired. It could be as simple as lint in connector making the pins not connect electrically (or even physically preventing proper insertion). It also could be an internal failure (corrosion due to liquid damage or just a fault in the circuitry without an external cause). You can follow the examples given in this Q&A to troubleshoot dock connectivity issues