Automatically change system volume when audio device plugged in?
Fun fact for everyone with a Realtec sound device (almost everyone):
Uninstalling your vendor driver and reverting back to the Windows default driver enables headphones / speaker differentiation.
(Tested on Win8.1 and 7)
Open the volume mixer (click the speaker icon in the system tray and choose "mixer"), you will probably find the left-most column (Device) will say "Speakers". Click the down-arrow next to this icon - this allows you to choose other devices, such as headphones, and you can then adjust them seperately.
If headphones isn't given as an option, or there's no down-arrow, you may need to right-click the speaker to access further option to unhide the headphones. Alternatively make sure you try this with the headphones connected.
Alternatively you can adjust these using the Sound options in Control Panel, again make sure you unhide disconnected / not active / I-forget-the-term-it-uses devices if you don't see headphones listed at first.
If the headphones option is missing (especially when they are connected) from the mixer and in the Control Panel sound options, then I'm afriad you computer cannot tell the difference between when you are using your speakers or headphones - meaning there is unlikely to be a software solution.
Realtek Devices:
Try to open "Realtek HD Audio Manager" in Control Panel. At top right of the opened window click on "Device advanced settings" and finally on this menu choose "multi streaming mode".