Role of Resistor at the output of a comparator
A lot of comparators just have an open-collector output and this is normally used by connecting a pull-up resistor to a positive supply rail. In your circuit you have shown a TL081 (written since the op edited it to an LM311) and this doesn't qualify as a comparator - it's an op-amp and as such, it doesn't need a pull-up resistor.

Here's a circuit of a typical comparator, the LM339: -



It wouldn't work without a pull-up resistor or something to supply current to the output like an LED: -