If the food is really hot then I let the food cool down for a minimum of 30 minutes which is usually enough time to allow it to cool down to at least warm.
Then I put it in the refrigerator after 30 minutes of cooling down.
If it's not too hot then I put the food in the refrigerator right away to keep it from growing bacteria.
You don't have to cool food first before putting it in the refrigerator but it does help keep the refrigerator from working as hard with the hot food in it.
Or you could place the hot food into the freezer for 30 minutes and then put the food into the refrigerator.
If you cook the food and then eat some of it then by the time you get done eating the food that is leftover would be cool enough to refrigerate.
But in my experience 30 minutes is good enough time to let the food cool enough before refrigerating it.