There is wide disagreement even among veteran painters about whether to paint woodwork, such as trim, baseboards, and wainscoting, before or after painting walls. It comes down to personal preference. The argument for painting woodwork first is that any stray drips or spatters that end up on the wall only need to be feathered out, not removed, since the wall's going to get a new coat of paint anyway. If you get all of the slow, detail work out of the way first you'll feel as if you're flying right along when it's time to fill in the big, flat areas. On the other hand, rollers always emit a powder-fine spray of paint into the room. No matter how careful you are, some of it is going to end up on the woodwork.
Whether you decide to paint the woodwork first or last, be sure to inspect it for defects, and make the necessary repairs before you actually get down to painting. If you'll be painting over already-glossy woodwork, sand it lightly with sandpaper or steel wool first to help with adhesion. Or, give it a coat of deglosser.