This is question that should primarily be answered by theoretical physicists, as mathematicians always are going to want to say to take more math.

I am going into my third year of undergraduate study major in math and physics and I hope to eventually end up in a good theoretical physics PhD (probably cosmology or particle physics). I have the ability to add a year at my current institution and do a masters in math, and I am trying to figure out if pure math at a graduate level is interesting/useful for serious theoretical physics.

Some classes I would be interested in taking as part of the degree would be (all grad level) Functional Analysis, Complex Analysis, Lie Algebra, Differential Topology, Riemannian Geometry, Theory of ODEs, Theory of PDEs, Operator Algebras, Real Analysis, Topology, Algebra (a lot of these classes are two semester sequences).

I am interested in hearing how useful people think having such a formal mathematical education would be to doing the physics. I am primarily interested in very foundational physics, and I am concerned that the brief treatment the math is given in physics books will prevent me from having a full understanding of the math at play in fields such as QFT and some the more out-there cosmology. I of course understand one can self-study some of these topics, but it seems fairly clear one would get a deeper appreciation by actually taking the courses in a proper academic setting.