The force due to gravity is a conservative force. The work done on a closed path by the conservative force is zero. Hence, for every complete orbit of the comet, the work done by the gravitational force is zero.