You can't. Pin 2 of the Raspberry Pi expansion header is connected
directly to the USB power supply — it isn't controlled by the CPU.
Do not try to connect the fan directly to a GPIO pin; not only do they
not output the right voltage, but they can't source/sink enough current to
run the fan either. Trying to do so is very likely to destroy the pin
driver, and may cause damage to other parts of the BCM2835 as well.
If you need to turn a 5V fan on and off, you will need some support
hardware to control it (e.g, a FET).