QuickTime alone won't capture computer audio along with a screen capture, but combined with a free utility Soundflower, you can do this.
MacWorld has a step-by-step guide, but the basic idea is to install Soundflower and set your computer audio out to Soundflower, so system sounds play to it and not to the speakers. Then in QuickTime, when you set up a new screen capture, select Soundflower as the audio source. Then you can do a screen recording and capture system audio at the same time.
Note that this is the free but messy version. Software like Screenflow does this sort of thing very well, but costs $99.