A properly installed and loaded wall switch should never get much warmer than room temperature. If a wall switch feels hot, or even very warm, it is an indicator that something is wrong and requires immediate attention.
The switch may be handling too much power. Many switches carry a rating of 15 amps for use in 15-amp lighting circuits; however, many people think that all switches are the same and install them on 20-amp circuits. Such switches cannot handle the extra load safely and require replacement with 20-amp switches immediately.
When switches wear out, they can arc slightly when turned on and off, causing a small spark and burn on the electrical contacts. Eventually, the contacts fail to meet properly, causing electricity to flow through a smaller area, generating heat. A switch in this condition is a fire risk and needs replacement.
A loose or broken, but still touching, wire on a switch can still function but will force the electricity to take a smaller than intended path through the wire. This creates excessive heat. Both of these conditions require immediate repair, as they present a fire risk.
A dimmer switch is the exception to the rule of what to do when facing a warm wall switch. These switches do intentionally get warm, as dissipating the power of the electricity to lights is how they function. If in doubt about a dimmer switch, refer to the manufacturer's temperature ratings for the switch.