Stick painter's tape to the wall surface to protect against brush strokes or splattering.
Hold a "paint guard" firmly against the base of the trim, pressing back the carpeting. Paint guards are sold at most home improvement stores. These tools are basically thin, sturdy pieces of metal with an attached handle. The straight metal edge fits snugly against trim and protects underlying carpeting from paint drips, splatter and brush strokes. The practice works well for common medium- and low-pile carpeting. But if you have shaggy, high-pile carpeting, the paint guard will be ineffective; you should completely replace the trim with new, pre-painted trim.
Apply a general purpose interior primer to the trim using a regular paintbrush. If the trim is wooden, apply your primer perpendicular to the wood grain, as this works the primer into the pores. As you prime the trim, move the paint guard along the trim to continually protect your carpeting from the primer. If the paint guard becomes overly saturated with primer, rinse it off with a garden hose or in a stationary tub.
Wait for the primer to dry.
Apply a coat of oil base or acrylic latex paint to the trim using a clean paintbrush, using the paint guard to hold down the carpeting and maintain a clean edge. Rinse the guard as needed during the painting process.
Wait for the first coat to dry.
Apply more coats of paint if needed.
Remove the painter's tape when the final coat is fully dry.