I like the idea of using foam to fill the gaps, it will insulate the void and provide a support for the backer rod. However, everything depends on getting the foam at the correct depth: too shallow and the backer rod will still fall back into the void...too much fill and the backer rod AND caulking will not fit.
So, be sure to mark the depth required and practice with the foam on a sample board to see how much you can fill, how much the foam will continue to expand and where it stops for the correct depth.
A word of caution, if the window is old, the frame could tend to twist and move out of alignment when the foam is applied to one-half of the window frame. How sturdy is the window frame?
Also, a backer rod is required, you can't just caulk back to the foam. A backer rod is actually a releasing agent so the caulking will stick to the two materials on the sides (in your case, brick and wood frame) and not to the material behind the caulking. DO NOT OVER FILL. It's not how much caulking you can get in the joint, but rather the proper depth. Most people fill too deep. Most manufacturers recommend a ratio of 3:1. That is to say, 3 wide and 1 deep. This allows the caulking to expand and contract and still stay adhered to the sides. So, if the joint is 3/4" wide, do not fill any deeper than 1/4".
By the way, to me, caulking and sealant are different. Latex caulking is paintable, but dries out over time. Silicone sealant is more flexible (better for locations with movement due to thermal issues, etc.) but can't be painted...as easily.) I doubt if there's a lot of movement between these two materials.