When talking about the planet Earth, it is a proper noun and is always capitalized. When talking about soil, or dirt, then earth is not capitalized (except when used as part of a title).
Your example sentence is correct. Another example if you need more proof, but there are many more on Google.
Another example using "earth"
[Edit] Apparently some editors are lazy. In common usage, the name of the various celestial bodies is often not capitalized (possibly because apparently it's too hard to reach the "Shift" key). Such is the evolving nature of English in a technological age, lol.
Anyway, this might be a better example -- although I would look specifically at the responses by the "experts" and not the questions themselves.
So a more comprehensive answer is that while perhaps Earth should be capitalized when talking about the planet itself, it often is not. It also may not be capitalized when talking figuratively about a large region of the planet, e.g. "his empire stretched from one side of the earth to the other", or in an idiom like "to the ends of the earth".