IPhone glitches when headphones are plugged in. Solution?

I have an iPhone 6, and every time I plug in my headphones, my music starts playing. Or if I'm listening to music, it just stops. Even when I pause the music that is playing, it just plays again and it keeps happening until I unplug my headphones. Or if I'm watching a video, same things happen. And also, sometimes it just goes on Siri instead of pausing or playing. Any solution to it?

Buy a better phone