I had a bike with a threaded headset that kept coming loose every time i ran on rough roads. Also noticed the pinging noise. Kept tightening it as much as I could, to no avail, finally took it apart, found that the keyed washer between the locknut and the top race had been twisted through the threads and stripped so the key wasn't really doing anything when I tightened the locknut.
Replaced the washer, tightened the nut down properly (helps to have a headset wrench to hold the top race), and no issues since.