The load balance is task of the operating system, but you must compile your code as multi-threaded. And all linked libraries must also support this feature.
Read the
Microsoft documentation for some details.
Switching threads on different kernels is "costly", so it isnt a good idea to enforce it. Better ways of optimization is a sound architecture and clean program flow ie resource accesses. ;-)