Bipolar Junction Transistors
To add on the @Barry answer, switching losses also depend on time at which you switch, ie. The amount of current or voltage across the switch. This is why in high efficiency applications, power electronics designers choose to employ what is classed as zero voltage switching or zero current switching.

To better understand this we can refer to the graph below:



Whenever you give a command (ON or OFF) it takes time for the device to achieve its final state. This is to do with movement and recombination of charges within the device.

So lets assume there is a certain voltage across the switching device, and the switch is Turned on. The voltage takes time to drop and similarly the current takes time to achieve its final value. Using \$P=VI\$ we can determine the switching loss.

The model above is highly simplified, in reality the curves are non linear.