There are many ways to do this. The most common
way is to use a good quality painters tape like
Dynamic
EdgeWise which will prevent paint from getting
onto the trim and yet can be easily removed. Another
method is to use a paint edger
which has wheels on it to keep the paint away from
the trim or you can get a trim guide
(Dynamic has a variety of sizes and shapes to choose
from) which you hold against the trim, paint that
stretch and move to the next stretch.
This is a common problem due to corners not being
really square and other issues. The best advice
we can give is to first sand the corner really well
with a square Dynamic sanding sponge
(making sure to sand both sides evenly). This will
help square up the corner. After you have wiped
down the corner with a tack cloth, paint the wall
with the lightest color first in such a way the
the corner where your two colors will meet is well
covered. After letting the light colored wall dry
for at least 24 hours, use Dynamic
EdgeWise tape to make your line. Tack the tape
first at the top of the wall and reel off enough
tape to go all the way to the floor. Holding the
tape tightly, try and tack it next at the floor
so that the tension you kept on it keeps it straight.
Once you are satisfied that your tape line is straight,
run your hand over the length of the tape to give
your first color the protection it needs from your
second darker color. Paint - remove tape after 24
hours.