Back up all data to at least two different storage devices, if you haven't already done so. The backups can be made with Time Machine or with a cloning tool such as Disk Utility. Preferably both. You must be certain that you can restore everything to the state it's in now.
Boot into Recovery, launch Disk Utility, and erase the startup volume. This operation will destroy all data on the volume, so you had be better be sure of your backups. Install OS X. If your Mac was upgraded from an older version of OS X, you’ll need the Apple ID and password you used to upgrade, so make a note of those before you begin.
When you reboot, you'll be prompted to go through the initial setup process. That’s when you import the data from one of your backups. For a walkthrough, see here:
Using Setup Assistant
Don't import the Guest account, if it was enabled on the old system.
Note: You need an always-on Ethernet or Wi-Fi connection to the Internet to use Recovery. It won’t work with USB or PPPoE modems, or with networks that require any kind of authentication other than a WPA or WPA2 Personal password.