Hi there,
You need to check if its the headphones them selves or if its the phone.
Try a different pair of headphones, and if the do it too then its the phone its self.
Otherwise the most probable answer almost defiantly is the headphones, which if it is then you need to wriggle different parts of the cord to see if you hear different crackling coming from different spots.
If there is then find where that spot is, and you could rewire that certain part. Most likely theres a broken wire that needs repair. Otherwise if its the speaker on the headphone, it could be a speaker issue.
Hope this helps