The only reason that the subsurface rock is cooler than magma is being able to conduct heat through to a cooler surface. When that surface becomes exterminatingly hot and remains so for a while the subsurface will be heating up too. Since the sun is estimated to remain a red giant for about one Gy it will become hotter than the surface.