Go to control panel -> Realtek HD audio Manger
In the top right corner, there's a little yellow folder called "Connector Settings”.
There, you can find setting "Enable pop-up dialog, when device is plugged in.
Plug in an headphones and select the option "headphone". Then the sound comes out only through the headphones