The correct statement is:
A solar eclipse occurs when the moon casts a shadow on Earth, and a lunar eclipse occurs when the Earth casts a shadow on the moon.
So to complete your sentence, it would be:
"A solar eclipse occurs when the moon casts a shadow on Earth, and a lunar eclipse occurs when the Earth casts a shadow on the moon."