The fan is not connected to the GPIO. The GPIO are 3V3 and only supply a few tens of milliamps of current. The fan is connected to the 5V and ground rail.
You will need to add circuitry to switch the fan on and off. The simplest is probably to add a transistor. The transistor would sit between the 5V supply and the fan. A GPIO could then be used to switch the transistor on and off.
You would need to write the control software to switch the GPIO/fan on when the Pi is too hot.
Hobby electronics shops should be a good source of typical transistors.
I'd probably aim for something which could switch at leas 500mA of current.
E.g. http://www.hobbytronics.co.uk/electronic-components/transistors/tip31c is overkill, but the others on that site only switch 100mA.
Once you find a suitable transistor its specs will show how much current is needed to the base to fully switch it on. Then calculate the needed resistance to allow that current to flow from a 3V3 GPIO.