If the malware is removed in your case, you'll still need to make changes to the way you use the computer to protect yourself from further attacks. That's why you can't rely on software to protect you. There is no such thing as automatic removal of all possible malware, either by OS X or by third-party software. Again, some kinds of malware will be removed-not all.
If you're already running the latest version of El Capitan, you can nevertheless download the current updater from the Apple Support Downloads page and run it.
If you're not already running the latest version of OS X ('El Capitan'), updating or upgrading in the App Store may cause the adware to be removed automatically. But before you follow those instructions, you can attempt an automatic removal. Some of the most common types of adware can be removed by following Apple's instructions. You may have installed ad-injection malware ('adware'). That's how you cause problems, not how you solve them.
First, never use any kind of 'anti-virus' or 'anti-malware' software on a Mac.