How to fix a Samsung Galaxy A3 when it keeps freezing when earphones are plugged in

A

AC Question

I have a Samsung Galaxy A3 phone and I keep trying to use it with my earphones but whenever I plug the earphones into my phone it automatically restarts and if I leave my earphones in for a long time it goes into an endless cycle and it keeps restarting without stopping.