When were the most massive elements (such as those that make up rocky planets like Earth) formed?
Stellar ejection theory postulates that heavier elements (beyond hydrogen, helium and lithium) were formed by earlier stars that existed before our Sun.
As we know, our Solar System isn't the earliest item in the Universe; many other things have existed and disappeared before our Solar System.
It is postulated that massive stars that formed before our own Sun could have created the heavier elements that now exist by gravity, fusion and heat. (I vaguely remember giving a complete answer to a question about how heavier elements were formed, but I can't find the link...)
When these stars went supernova (it is estimated that early stars went down the supernova II track) and these heavy elements were ejected across the early universe and unevenly distributed lumps of matter then formed our Solar System.