Sound automatically changing to maximum volume when headphones and charger are plugged in
I have a Macbook Pro 13" 2017 running Mojave 10.14.5. For some reason, if I keep my charger plugged into the laptop along with the headphones, the sound automatically goes to maximum. When I put it down, it goes back to maximum right away. I tried doing the option+cmd+p+r sound reset, but that seemed to do nothing. If either my charger or headphones is not plugged in, the problem does not persist. I have tried restarting the computer several times. The problem happens regardless of what apps are open. I also tried to stop the coreaudiod and let it restart.
Any help would be appreciated.