Wet a toothbrush in bleach. Scrub the grout line along the molding where it meets the popcorn ceiling, getting it completely clean of dirt and any loose material. Let it dry.
Set a caulk tube in your caulk gun. Cut off the end of the tube at a 45-degree angle, making a hole about 1/4-inch across in the tip.
Push a 3-inch nail into the hole, breaking the seal inside to release the caulk. Squeeze the trigger of the gun until caulk emerges from the end. Press the release latch at the back of the gun to stop the caulk flow.
Set the tip of the tube against one end of the molding, while holding the gun at a 45-degree angle. Compress the trigger until the caulk comes out the tip.
Pull the gun slowly backward along the line between the molding and the ceiling, letting the caulk fill the space and seal to the ceiling. Don't stop once you start, making the bead go along the whole length of the molding. Pull the gun away from the molding at the end, and hit the release latch at the back of the gun to stop the caulk flow.
Run your thumb over the caulk line from one end of the molding to the other to smooth it out. Repeat for each span where the molding meets the ceiling.