Set Headphone Mic Boost gain to 10dB. Any other value seems to cause the irritating background noise in headphones. This can be done with amixer:
amixer -c0 sset 'Headphone Mic Boost' 10dB
To make this happen automatically every time you headphones are connected install acpid.
Start it by running: sudo systemctl start acpid.service
Enable it by running: sudo systemctl enable acpid.service
Create following event script /etc/acpi/headphone-plug
event=jack/headphone HEADPHONE plug
action=/etc/acpi/cancel-white-noise.sh %e
Then create action script /etc/acpi/cancel-white-noise.sh
:
#!/bin/bash
amixer -c0 sset 'Headphone Mic Boost' 10dB
Now Headphone Mic Boost will be set to 10dB every time headphones are connected. To make this effective you need to restart your laptop.