I'm having trouble getting sound to work on some apps and even when I lock/unlock the screen. Any suggestions?
Screen locking will not change the sound.
However...The side switch is the key. Depending on your settings, it may affect the mute or it may affect the rotation lock. Whichever function it supports, the other function is performed by a "soft switch." This support article from Apple provides detail.
In case you're wondering, here is the history. Originally, the mechanical switch affected only the rotation lock and the mute was a software switch elsewhere. In IOS-3, it was changed to be the mute switch and the rotation lock became a software switch. This was done to ensure consistency among IOS devices. Unfortunately, a large quantity of users complained loudly, alleging that they turned the rotation lock on and off several times every hour and the convenience of the mechanical switch is essential. In IOS-4, Apple bowed to the whiners and made the switch function selectable and now we're stuck with a mess.