Why does overclocking a CPU cause it to generate more heat? It seems odd to me that overclocking a CPU causes it to consume more energy.  
The amount of energy flowing through the CPU should be related to the average number of 'gates' (or transistors) that are open, not how fast you open and close them.    
Does changing a transistor's state cause heat to be generated or is there another factor?
 A: Modern processors are built from CMOS technology.  These digital circuits consume relatively little current when sitting in one state or the other.  However, there is some inevitable capacitance on every node.  When the output of a digital gate changes state, that capacitance is charged or discharged, which means current has to flow.  The total average current used by a digital gate is therefore largely proportional to how often it switches, which is to say it is proportional to frequency.
The supply current times the supply voltage is the power used by the digital circuit, which it dissipates as heat.  So yes, clocking a modern processor faster causes it to dissipate more power, which can cause it to overheat if this power isn't removed properly.  Note the big heat sink with dedicated fan clamped to the processor chip.  Getting rid of the heat of such chips is a major design consideration.
Newer processors also draw significant power just because they are on.  One way to reduce the power required for switching is to lower the voltage.  That reduces the charge that is moved onto or off of the little capacitors each digital state change, which reduces the overall average current and therefore the heat dissipated.  However, when the transistors are made for too low a voltage, they don't really turn off that well.  This results in a little leakage current thru each gate.  A few million gates here, another few million gates there, and pretty soon you have some real currents to worry about.  This tradeoff between less current due to switching versus more current when not switching is a carefully balanced design decision.
