Does the screen dim first, then turn off? If so, that sounds like the normal screen timeout. Even if you're playing a game, the screen could potentially timeout if you haven't touched it for the whole timeout period. An app would have to be properly coded to keep the screen awake beyond the timeout period (aka, a full wakelock).
However, this shouldn't happen at all with YouTube--you're sure it's happened when watching a video?