Use Firefox as your web browser, with Ad Block Plus installed: Can be found here.
Assuming that you are on windows:
Make sure that your operating system is fully up to date on its patches.
Scan your computer for viruses and spyware with more than one security program, like AVG Free, AdAware (free edition), and Spybot Search and Destroy (use the Immunize functionality of Spybot S&D; it will modify your "hosts" file to prevent your computer from even resolving some bad websites.)
Uninstall add-ons and browser extensions that you don't need or want, as sometimes they are the source of unwanted ads.
If you're technically proficient, use Autoruns to carefully change what programs are starting up when your computer starts up.
Also make sure that all of your software is up to date and patched. This is pretty hard in operating systems that don't have "package repositories" (IE: most things that aren't Linux), but you can use programs like Hippo Update Checker to find updates to some programs.