You can use variables. For example, when press the punching key, change animation to punching, and also set the variable "punching" to true. Then, in the collision, check if the variable "punching" is true. When the punching animation finishes, set the variable to false.
If you need the collision to be only in the player hand, instead of the whole sprite, you can create an invisible object, and always set its position relative to the player position.