Door framing is typically larger than needed. It's a routine practice that allows the installer to adjust the door as needed to fit plumb, so that the door works properly. The frame is wedged in tight when the installer places shims between the stud frame and doorjamb, resulting in a gap around the perimeter of the door frame where the shims are used. Trim carpenters usually cover the gap with door casing. But if you desire to take it to the next level, add some spray foam -- which is sometimes used on window frames -- to fill the gap before adding the casing.
Insert the end of the straw on the can of spray foam into one of the gaps between the shims. Pull the trigger on the can. Do the interior side of the door first.
Move the can up or down to fill the gap two-thirds full. Allow the foam to expand flush with the door frame. Move the straw to the next gap up or down and repeat until all the gaps between shims are filled.
Move to the exterior side of the door and repeat Steps 1 and 2. Allow the foam to dry on both sides.
Measure up from the floor to the top inside corner of the doorjamb. Add 1/4 inch to the measurement. Set the blade of a miter saw to 45 degrees. Cut two pieces of door casing for the interior side; one with a left-hand miter, and one with a right-hand miter, taking the measurement from the short points of the miters.
Place both door casings over the gap with the mitered corners opposite each other at the top. The door casing should be 1/4 inch from the edge of the doorjamb to provide the customary 1/4-inch reveal or lip between the doorjamb and casing.
Shoot 2-inch finish nails into the casing spaced at 12 inches using a finish nail gun. The nails should penetrate through the casing and into the stud frame to secure the casing and cover the gap.
Measure the distance horizontally between the two mitered corners at the top from the short points of the miters. Using the measurement, cut one piece of casing with one left-hand and one right-hand miter.
Place the top horizontal piece on the top of the frame, matching the vertical mitered corners with the horizontal mitered corners at the top. Shoot finish nails through the top piece, spaced at 12-inch intervals.
Fill the nail holes with wood putty using a putty knife if the casing is not finished. Fill the nail holes with putty crayon if the casing is finished.