From TF2 Wiki
The Dingaling is a sound generated when you activate the "play hit sound when you injure and enemy" in Options, Multiplayer, Advanced.
The volume can be adjusted with tf_dingaling_volume. Though the volume stays consistent despite distance and obstacles between the player and the target. If a player causes damage to someone across the map and behind two walls the sound will play at the same volume as it would if the target were right in front of them.
It is the same as the critical hit sound under normal circumstances, however using the console commands tf_dingaling_pitchmindmg and tf_dingaling_pitchmaxdmg one can vary the pitch of the sound so it is based on the amount of damage done. For example, setting tf_dingaling_pitchmindmg to 150 and tf_dingaling_pitchmaxdmg to 5 causes the sound to decrease in pitch as more damage is done. Light damage from a pistol or syringe gun will play light and short dings. Conversely, a critical hit or headshot will produce a lower pitch sound that continues to echo for a longer period, sounding much like a gong. Projectiles reflected back at the player by compression blast do not set off the noise, however any projectile the player reflects is treated as their own. So the pitch will adjust for the Mini-crit bonus of a reflected rocket, as it does for every other bonus for the various classes.
Using this option can allow the player to get instant feedback on how effective they are in combat, since it gives an audible cue for when their shots land. Using the pitch to determine damage goes even further in this aspect, as one can confirm headshots and average damage without visual confirmation. This means Huntsman Snipers can confirm headshots after firing even as they begin ducking behind cover to avoid counter-attacks. If they land a body shot, they can adjust their aim accordingly before leaving cover again. The damage numbers displayed option achieves similar feedback, but can clutter the screen when repeated damage is done and can be hard to concentrate on while in the middle of battle.
The sound does not play when hitting cloaked spies or Buildings even though it still does damage to them. The Pyro's afterburn causes the sound to play every time damage is registered. A Spy who is ignited while cloaked will not set off the sound until he uncloaks or dies. In the latter case there is a single ding along with the kill notification. The sound also stops when the Dead Ringer feigns the spies death, but resumes as normal when he uncloaks. For Pyros, this means that one can tell when Spies or other targets are still alive even when they lose sight of them for as long as the afterburn continues. If the sound stops after the Spy was last seen headed towards a room with an extinguishing source, it can be assumed they are still alive. Attentive Pyros will be able to guess if a Spy is using the Dead Ringer if the sound stops while the Spy was at high health and away from extinguishing sources.
The sound does not take constant healing into account, so a target that is being damaged while next to a Dispenser or healed by a Medic will play the sound at the same pitch as it the target wasn't being healed, even if the damage is nullified by healing right afterwards.
As the sound can cover up other important audio cues, such as Spies uncloaking, it is up to the player whether or not the trade-off is worth it for the advantages the sound gives.
Using the console command tf_dingaling_wav_override allows the player to use a sound file from their computer in place of the normal dingaling. Alternatively, the file can be replaced by placing a sound file in the teamfortress2/tf/sound/ui folder and naming it "hitsound"