Hi,
The problem with your circuit is, that LEDs can withstand only 5V in reverse polarity.
For this the resistor is no protection, it just limits the current.
The use of your circuit is to check polarity, thus it is not unlikely that the applied voltage is in reverse.
To protect the LED I recommend to connect a small signal diode (like 1N4148) in series with your resistor.
I also recommend to connect a resistor (same value as the currently used) to connect in parallel with the LED.
This even more protects the LED and prevents it from dim shining with low currents applied.
Klaus