The best way I have found to protect carpet while painting baseboards is to use wide masking tape over the carpet. This is a little tricky to do, but fast once you "get the hang of it".
Use wide, 2 inch, painter's tape. The type doesn't matter but blue painters tape is a little easier to work with.
Begin applying the tape by wrapping a little, 1/4 inch, onto the baseboard at the carpet. Then force the tape under the base edge with your fingers. This small amount of tape under the baseboard will hold back the carpet and protect it while brushing. Once you get the hang of it, it is very easy and fast.
A strip of masking paper can also be applied to the tape for more protection.