Can command blocks detect punches with certain items?
Put this command into a repeating command block and it will summon tnt that will instantly explode on every entity that gets hurt close to a player holding a stick.
execute at @a[nbt={SelectedItem:{id:"minecraft:stick"}}] run execute at @e[distance=0.1..5,nbt={HurtTime:10s}] run summon tnt ~ ~ ~ {Fuse:0}
The command does NOT detect, HOW the entity got hurt, but it seems to often not work when the entity gets hurt by something other than a punch.