Its best to do regular baths and grooming at least once a month and at least once or twice a week brushing to keep up on it. If you let it go too long it can be very difficult to get them out and quit painful for the pup as well.
Everyone does things differently, its a madder of finding which tools work the best for you and sticking to routine grooming to avoid the worse of the mats and tangles.
I have a grooming page on my site and what tools to use and how to go about it if you want to take a look. The tools that I use are accross the bottom of the page.
Grooming - Dawn's Yorkies