Sound turns off when Mountain Lion sleeps
Sleep mode is designed to suspend apps so the system can sleep. (All apps and most of the OS stop executing and some hardware is turned off to save battery.)

There is no fix for this other than setting your system to not sleep. You can do this permanently in the Energy Saver preference pane or temporarily by using an app like Jiggler or a command-line utility like caffeinate.