Some Linux distributions may not detect your headphones when you plug it in and just keep playing sounds from the speakers. I'm not going make this into a huge article, if your Linux doesn't detect your headphones, you can enable your Linux to automatically detect your headphones by installing Gnome Alsa Mixer.

To install Alsa Mixer, follow the steps below.

Step 1
Open a Terminal.

Step 2

Enter

sudo apt-get install gnome-alsamixer

Then it will ask for your root password, enter it.

Step 3

Now it will download and install Alsa Mixer. Open it from your applications.
Then tick "Headphone Jack Sense". This will enable automatic detect for headphones.