It's called detonation or tope...

Timing isn't correct. Have it checked or manually retard it. If you have a car with a knock sensor, then have that checked since the knock sensor prevents detonation from continuing.

Using higher octane gas is a temp fix, unless your car requires high octane to begin with.