If you want to write code that fires at specific points within a state, you can use a unique class of scripts known as State Machine Behaviours. State Machine Behaviours can be added to any state node you create within the Animator. I specify "you create" because you cannot add them to the Entry node, Exit node, or Any State node.
You can create a new State Machine Behaviour by selecting a state and clicking on Add Behaviour:
All new State Machine Behaviours created in this way are saved in the Assets folder.
When you open the script, it will be automatically populated with the following code:
using System.Collections; ...