Hi, S. Before you paint over knotty pine, you need to apply a primer/sealer like Zinnser's B-I-N. This is true whether it is new, raw wood or previously finished wood.
As far as sanding, this also needs to be done prior to applying the primer. The method depends on whether it is new, raw wood or previously finished. For new wood, I suggest about 150 grit with a sanding block or a finish sander. Here, you want to do a final smoothing. Cut a large piece (9 x 11") of sandpaper and fold it into thirds to get in any of the molding details.
For previously finished wood, you just want to sand lightly to roughen the surface. Again, 150 grit is about right and it will be just as easy to do it all with the quartered and folded sheet.
After sanding, vacuum and wipe down the area and then wipe it down again with a tac rag right before you apply the B-I-N. Any missing wood on the surface at the knots will show through but the knots themselves should not after the primer and paint.