Use Alex Dynaflex 50 year latex caulking. Cheap caulking is just going to crack. Only make a tiny hole in the tip of the nozzle, apply then wipe it in with your finger, then wipe the area down with a damp sponge. There should be 0 caulking on the face of the trim only just enough to fill the gap. If it's on the face of the trim, no amount of paint will cover it up.