How does the volume control work on my iPod touch?
You’re technically right. There are two settings, one for the speaker, one for the headphones. Both volumes are independent; if you have volume low on speaker and connect a headphone, you’re going to get the headphone volume, and that’s what you’re going to adjust until you disconnect it. 

Now, applications can alter the device’s volume, but they can also have their own independent volume level. For example a game might have a volume setting and if you put it all the way down, the ipod’s volume (alarms, music, etc.) is not altered. As far as I can remember (should check the latest iOS SDK) that is possible. 

Applications can of course mute themselves without altering the device’s settings.