Motor operating temperature is determined by the insulation rating. In North America, that would be Class A,B,F, and H. Class A is not considered a commercial/industrial rating so we have B,F, and H.
The temperature of the air around the motor plus the "degrees of rise" in the motor are added to get to the insulation's maximum temperature.
Class B is rated to 85 degrees C, F is 110, and H is 135.
So, for example, a motor has Class F insulation. If the environment is at 30 degrees C, the motor can rise 80 degrees C more to reach its rated temperature of 110. On the other hand, if the environment is at 50 degrees C, only 60 degrees of rise is allowed to reach a total of 110. Motors are normally rated at 40 degrees C for other reasons as well, such as bearing grease viscosity and grease life so running over 50 is not a good idea. Class H motors are usually only found around blast furnaces, heat treat ovens, and sometimes in TENV Inverter Duty motors.
As for that five second rule with your hand on the motor---just forget it! Considering that your skin starts to blister at 65 degrees C, even a Class B motor can fry an egg on its skin and be OK thermally.