The nofollow rel attribute value tell search engine spiders to "ignore this link", it dose not mean that links with the nofollow attribute won't be indexed.
Nofollow has a equivalent meta tag, which will tell spiders to ignore all links on a page.
Nofollow is used as a primitive defense against spammers. When used, the idea is that it will discourage spammers from posting links. This is however not always the case.
When to use it
Its a bad idea only to use it to prevent spam, because you will likely have to delete spam anyway, especially automated spam. Instead you should include it on links that you don't specifically approve. Brugbart doesn't necessarily recommend that you use it on your advertisements, unless you ain't in direct control of the ads that appear on your site.
This is based on the common sense, that you wouldn't normally accept junk ads on you pages. If your only reason for accepting an ad is the money, then it likely should be properly nofollowed. What this dose, is basically telling search engines, that you don't necessarily recommend the linked site, so they shouldn't count your link as a "vote".
Used in SEO
The nofollow Meta tag equivalent
You can also use a nofollow meta tag, which is to be placed in the head section of your page. Example below:
<meta name="robots" content="nofollow">
You may also want to read about robots.txt file, if you want to block search engines entirely from indexing certain pages.