Hello fandyboy,
Thanks for using the Apple Support Communities! We understand that when connecting headphones to your Mac the Music app will automatically start playing. Let’s take a look and see what we can do.
Let's test connecting your headphones in Safe Mode to see if the Music App plays automatically in there as well.
How to use safe mode on your Mac
Next, we can test to see if connecting your headphones in another user account has the same effect.
Set up users, guests, and groups on Mac
Lastly, we can take a look to see if Music is automatically logging in when you start-up your Mac and disable that to make sure it is not opened when connecting your phones. You will follow the "Add or remove automatic items".
Open items automatically when you log in on Mac
Please respond back if you continue to have any issues.
Have a great day!