Whenever I plug my headphones into my computer's front headphone jack, I get a weird situation. Sometimes, the computer will recognize the headphones and work properly. But other times, the computer will play sound through both the headphones and my monitor's speaker. When this happens, the sound section of the system settings does not list the headphones. I can fix the issue temporarily by wiggling the headphone port, but if it gets wiggled the wrong way again, then the issue returns. My PC's case is a Rosewill Challenger. I have tried multiple headphones and the same issue is there. I suspect that this might be a hardware related issue, but if there is any way to fix it with software, that would be helpful.

This is what it looks like when everything is working properly:

This happens when I wiggle the headphone port. I can quickly switch between these two by doing so: