system
Given the following post, respond as if you're commenting on Reddit:
human
What causes stars to switch from Hydrogen fusion to using heavier elements?

When talking about the life cycle of stars, people often say something along the lines of “when a star runs out of hydrogen to fuse into helium, it has to start performing fusion with heavier elements to keep producing energy.” But this glides over a lot of details and also frames the star as having some sort of agency, which is obviously not the case. 

So my questions are:

* Why does a star “have to” switch to using heavier elements? (I.e. why doesn’t it just die when it runs out of hydrogen?)
* Whatever mechanism causes the star to fuse heavier elements, why isn’t that process active during the entire life cycle of the star, including when there’s still hydrogen?

Thanks in advance!
gpt
In short, gravity compresses the core as fuel is exhausted, which raises the temperature, which eventually gets it hot enough to make the ash from the previous fusion burning stage to itself start fusing.

During the main sequence hydrogen slowly burns to helium, so helium is accumulating in the core. The star is in an equilibrium, where the thermal pressure is sufficient to drive H to He fusion (but not much He to C/O fusion) which balances gravity. But that's just a story we tell to children so they can sleep at time. 

Over the course of the H-burning main sequence life, you can see that the H is slowly getting exhausted. In order to keep up the rate of energy production to balance gravity, the core does have to get a bit hotter and denser because it has less H. So in reality, over the main sequence life of the star the core density and pressure are slowly increasing in order to maintain the balance- the core slowly contracts, increasing the density and pressure, and the equilibrium output moves slowly to a greater luminosity. As a result, the star finds a new balance- it gets more luminous and it grows, so its surface temperature decreases. This is very very gradual, and is not the transition to a giant phase yet. For most purposes, you can pretend that the luminosity during the main sequence part of the star's life is effectively constant. But if we're being honest, our sun is halfway through it's life and it is actually a few percent more luminous (and redder) than when it formed. 

If you repeat this process until the point where H fusion is not sufficient to balance the star, you'll find that the core contracts due to gravity. This drives it to greater luminosity, coincidentally, causing the star to slowly grow in a giant phase. Most importantly, the contraction causes the core to reach higher temperatures, and this is the key to getting your next stage of fusion burning. Due to the greater Coulomb repulsion between larger nuclei, they need greater kinetic energies (and thus temperatures) in order to burn efficiently. It is ultimately the core contraction (inside a growing star!) which heats the core enough to 'unlock' the next stage in nuclear burning. 

If you want to know more, the 'helium flash' is a really interesting feature of low mass stars as they make the transition to a giant phase and helium burning.