A theorem on higer-order derivative theories of gravity is proved. We find that the de Sitter/anti-de Sitter metric is always a solution of any generally covariant theory of gravity. With this theorem and a general form of entropy function for de Sitter spacetimes, we show how to calculate the entropy of de Sitter spacetime in a generally covariant theory of gravity without knowing the details of the modified metric. As an example, a general formula of dS entropy in Lovelock gravity is obtained.