Of course the 2nd Law applies to the earth! Just as it applies to a refrigerator, even though it exchanges heat with its surroundings. In these cases, the 2nd Law says that any decrease in the entropy of the system must be compensated for by an increase at least as great in its surroundings.
I guess I should have clarified - it does not apply in terms of an isolated system from an energy and entropy standpoint. The earth is not isolated, and does not have a fixed amount of energy and matter contained within it.