If the sun's internal plasma was at rest (the sun would have to stop rotating and other factors would need to occur), then I believe the magnetic field would dissipate and dissolve, essentially being 'demagnetized'.
However, because the star is rotating, and different layers of it at varying rates, the churning of the plasma (which is charged) generates the magnetic field as it moves past other charged plasma.
A stellar magnetic field is a magnetic field generated by the motion of conductive plasma inside a star. This motion is created through convection, which is a form of energy transport involving the physical movement of material. A localized magnetic field exerts a force on the plasma, effectively increasing the pressure without a comparable gain in density. As a result, the magnetized region rises relative to the remainder of the plasma, until it reaches the star's photosphere. This creates starspots on the surface, and the related phenomenon of coronal loops
Also, a central part you're missing in the relationship to metals on earth is that you're not reaching a plasma state with the metal. Above a certain temperature, a solid metal will reconfigure itself into random alignment (no aligned charges), but if you go too far and make it a plasma, it's essentially all charged nuclei. This just isn't discussed because a majority of people don't tend to make metals into plasmas on a very routine basis.