I posted about how I migrate an old Mac to a new Mac in a previous post.
After migration, I also wanted to do a clean install on the old Mac, and bring it to factory settings, but with the latest OS X (Mountain Lion for me).
It is very easy.
Restart computer and press Command + R while it restart to get to a menu screen
Select Disk Utility > Macintosh HD (your startup volume) > Erase
Go back to menu screen and select Install Mac OS X
Follow through and it will be done!