That all depends on what version of OS X came on it when it was new. If it is one of the newer download only versions, Lion or Mt Lion, then you use the Online Internet Recovery system, hold down the Command + Option/Alt + r keys until you see a globe on the screen, or if it came with DVD discs for reinstalling the OS and iLife programs.
Once that is known then the process is basically the same. Repartition the drive as One partition using Disk Utility, formatted Mac Extended (Journaled) with a partition table of GUID and then reinstall the OS. If it came with DVD discs then you supply those disc to the new owner.
You can't legally or practically transfer any software downloaded from the Mac App Store to the new owner of the machine, even if it was free. That includes OS X, so if you paid for an upgrade OS X 10.7 or later, you must reinstall the original OS, either from the installation media, if applicable, or by booting into Internet Recovery ( at the startup chime.)