In most cases, earth should be spelled lowercase, often following the determiner the when referring to the physical planet (The earth revolves around the sun and We stand on loose earth). Only when referring to the proper noun of the celestial body is it capitalized and written without the the. If the distinction between celestial body and simple planet proves mercurial, prefer the lowercase spelling unless certain the uppercase serves better.