Pattern for oscillation with LEGO Technic
What you're looking for is reciprocal motion, or to convert rotation motion into linear motion (and then back to a limited rotation).

Building out the key parts of the fan head you have the following setup (using fairly standard technic pieces:




Drive the smaller cog normally, this will rotate 360° as normal.
The driving rod will only move as far as the limits of the smaller cog - from the side you can see that this appears to be only going forwards and backwards.
The larger cog will be driven forwards a few degrees and then be pulled backwards as the driving rod is pulled back in return.


Adjust the distance between the gears and the size of the gears as you require. If you need a larger gear in (3) you could replace the gear with one of the liftarms with an axle hole rather than circles, etc.