You can erase your Mac and set it up so it is ready for a new owner by using the recovery partition. This hidden part of your hard drive allows you to boot into a special mode where you can erase all of the contents on your Mac and re-install the system. There are a few things you should do first, such as logging out of iCloud and deauthorizng your account in iTunes. By using a special security feature of Disk Utility on the recovery partition, you can ensure that your data is erased.
Here is Apple’s main page of information about how to wipe your Mac: What to do before selling or giving away your Mac.
Apple has more information about accessing and using the recovery partition at OS X: About OS X Recovery.
If you can’t use the recovery partition or an optical disc to wipe your Mac, you can try building a bootable external drive to use instead. Apple has some information on that at OS X: Installing OS X on an external volume. There is also a special tool from Apple that will help you available at OS X Recovery Disk Assistant v1.0