When a clownfish mother dies, her mate turns into the new female
In a clownfish anemone the biggest fish is the breeding female and the runner-up is her male partner. If she dies, he often bulks up and becomes female, and the largest of the non-breeding males matures to take his place. Changing sex partway through life is routine for hundreds of fish species.
Biologists call this sequential hermaphroditism: an organism makes sperm at one stage of life and eggs at another. In botany the same timing trick is called dichogamy. The switch is a normal part of the reproductive cycle, usually triggered by social position or by reaching a particular age or size. It shows up in many fish, snails and plants, and among vertebrates only the teleost fishes do it.
There are three directions. Protandry means starting male and becoming female, as clownfish and ribbon eels do. Protogyny runs the other way, female first, and bidirectional species can switch back and forth, sometimes more than once. Protandry crops up in such distantly related fish families that it almost certainly evolved several separate times; it is entirely absent in land vertebrates.
Protogyny is the more common route in fish: about 75 percent of the roughly 500 known sex-changing fish species start female. Size explains why. In systems where big territorial males monopolise mating, a small male has little chance to breed, whereas a small female can still produce eggs, so it pays to be female while young and male once large. Wrasses are the classic example. All California sheephead are born female and stay so for four to six years before their ovaries give way to sperm-producing tissue. Bluehead wrasses add a twist: small drab males carry larger testes than the showy territorial males, letting them compete by sheer sperm output.
Timing can also guard against inbreeding. In the colonial sea squirt Botryllus schlosseri, eggs are released about two days before sperm peaks. Self-fertilisation can still happen, and those embryos show cleavage anomalies far more often, 23 percent against 1.6 percent for cross-fertilised eggs. In flowers, separating the male and female phases was once thought to prevent inbreeding but may mainly stop pollen and pistil getting in each other's way.
Source: Sequential hermaphroditism