Chosen Solution
I have got an iPhone 4 (A1332) iOS 7.1.2 which I bought knowing there is a possible battery issue where the phone would randomly die even though there is battery life. However since receiving the phone I have noticed (with me) this issue only arises with my Apple earpods my non-Apple headphones doesn’t cause this issue. I have done a restore and I have a new battery with tools at hand but before replacing the battery I wanted to know if just replacing the battery will work or if there could be another problem?
I don’t see how a faulty earphone jack would cause the phone to immediately shut off unless it was water damaged or something was shorting the earphone jack. Since you already have a new battery at hand it’s worth a try replacing the battery and testing it to see if it the issue still occurs. You will only have to plug the new battery in when testing so in case that doesn’t solve your issue you can put the new battery back in its packaging.