The solution to this problem was not created by me, I found this solution . However this should make the process a lot faster.
First download the python script already created by the process I found from .
Save it to your home directory, (this will make it quickly accessible when you need to fix your sound) and save it as something simple like s (for the same reason).
Once done you now have the script that fixes your computers sound with headphones. Whenever you have headphones plugged in and sound is not working, run the script in a new terminal window where you saved the file and run:
If your headphone sound does not work after running this, try running it a few more times.