What's probably happening is that the CPU goes into a more aggressive power-save mode. This causes the internal switch-mode voltage regulators to go into a pulse-skipping mode, moving the switching frequency down to the audible range. The noise comes from the inductors and capacitors, both being slightly microphonic (which also works in reverse; the emit sound)
It's a lousy design, but you're stuck with it.
The "best" way to solve it is to go into BIOS and configure your CPU for a less aggressive throttling. This would prevent all the fancy power saving modes to kick in, so you don't have to mess with these tasks.
Another way is to run a useful task, for example SETI@Home or some other thing you might want to do. I think SETI@Home can set a CPU limit percentage, but if not, you may be able to use the
cpulimit linux command.
The least interesting way is to just burn up cycles with one of the stress-test utilities. techraf already suggested stress-ng, and there are a few other similar utilities.
If you can not find a utility with a fine-grained enough throttle, I whipped up this perl one-liner for you. The throttling can be tweaked. I use perl because that's what I know. Insert your favourite programming language.
perl -MTime::HiRes=sleep -e 'sleep 0.0001 while 1'
Changing the 0.0001 part will make it use more or less CPU.