Fix Larger Gaps With Backer Rod
For large gaps you might need to use backer rod to fill the space. Measure the gap from side to side and cut a piece of backer rod to fit. Add a bead of caulk to one side of the cut piece and push it into the gap. Push it as far into the gap as possible, then push it into the space as far as it will go. Larger gaps might require more than one piece.
Once the space is filled, caulk both the upper edge and the lower edge, and don't worry about getting a perfect bead. No one will see your handiwork -- the goal is just to seal off any air penetration. Stick the decorative trim against the caulked area then drive in some finishing nails to secure it.