The Earth has an iron core because iron separated into a separate chemical phase that was denser, and this denser phase percolated downward into the center.
The Earth does not have its iron core because individual iron atoms, being heavier, individually diffused downward into the core. Some heavy elements, like uranium, are actually highly concentrated in the continental crust, because chemically they partition into lower density phases.
In the Sun, with everything inside vaporized, there is and was no partitioning into distinct chemical phases of differing density. There is a chemical difference in the Sun's core, though: it is now enriched in helium and somewhat depleted in hydrogen because of nuclear fusion over billions of years. This process is gradually making the core denser and hotter, increasing the overall rate of fusion. The Sun is now 30% brighter than it was when it settled onto the main sequence.
Separation by mass of ions does occur in the surface layers of white dwarf stars; the conditions there are such that separation by diffusion can be significant. Some such stars have been seen with "metals" (elements heavier than helium) in their crusts; this has been interpreted as evidence of recent accretion of material from disrupted asteroids or planets.