Can I ask if you have tested other headphones to see if the same thing happens?
Yes. A few different types. From high end to dollar style all the same. I've only tried one set of bluetooth headphones and I'm not sure if it was the phone or the headphones
If the same thing is happening with several different sets of headphones, then it typically means something internal with the phone is going wrong. I'd recommend service repairs to have a technician evaluate the phone. There are a few options for this. The first option is speaking with your carrier, they sometimes have options available that Samsung cannot offer. The second would be visiting a walk-in service center such as uBreakiFix. uBreakiFix is an authorized service center for Samsung capable of completing both in and out of warranty repairs. The final option is the ship-in service through Samsung, It's a 7-14 business day process including shipment and repairs. Should you decide to move forward with the ship-in option, you can send me a message here with your full model code and IMEI: http://bit.ly/2igAXKH
I know this isn't a perfect fix, but if you find out it is the 3.5mm port that is the problem, and the phone is out of warranty or you do not want to pay to repair it, you still have 2 options for wired headphones.
1. USB C to 3.5mm jack adapter ($8-$10), for using your old 3.5mm headphones
2. USB C headphones