How to capture audio with Quicktime Screen Recording
You could use Audio Hijack (per Tetsujin) to capture the audio as needed or you could use a USB audio adapter to do it for significantly less.

I use the Behringer UCA202 Audio Interface with my iMac.  



When I needed to record a screencast with the audio from the application, I just used an RCA audio cable I had laying in a drawer similar to the image below.  You don't need anything fancy or expensive, just a standard RCA audio cable.



In quicktime, I just selected the USB device as my input:



Now, when I say significantly less, Audio Hijack is about $50 if buying the new license.  The USB Audio device is $30 and if you have to buy an RCA audio cable, you're looking at another $5.  So, for $35,  you get an audio interface that has many more uses than the software can provide (for example, I can hook my Bose Wave Radio to my iMac now) whereas the software doesn't allow you to do that.

Make no mistake, Audio Hijack is good software.  This is just another, albeit less expensive, avenue to solve your problem.