I made this circuit but no matter what the input Voltage is, the output stays high and the led lights. Is it because of the offset voltage ? And where to connect the offset nulls to make the output zero? It did not work when I connected the to ground
An ideal opamp-based comparator multiplies its input difference (Vdiff = Vi-pos – Vi-neg) by its open-loop gain (Ao).
But there's always a non-zero offset voltage (Vos) which should be added to Vdiff. So the actual comparison equation turns into Vout = Ao (Vdiff + Vos). This equation tels us that;
If Vdiff +Vos if greater than zero then Vout will hit the positive supply rail.
Likewise, if Vdiff +Vos is lesser than or equal to zero then Vout will hit the negative supply rail.
Thus, even if Vdiff is zero then the output will hit either negative or positive rail depending on the sign of Vos.
As for your question, since the output hits to the positive supply rail when Vi-neg = 6 VDC regardless the value of Vi-pos, the source of the problem shouldn't be the offset voltage.
You may try adding a potentiometer to zeroe the Vos like following anyway: