cops not under cover should still look and dress professionally, considering at any point in time they can be called to duty.
undercover cops need to be especially careful under cover, and should not be armed as they are not supposed to be identifiable as cops (no badges). if they are, they need to be treated as any other unlicensed criminal for the sake of their cover.
it is rare the undercovers get caught by uniformed police, but if they do they go through the motions but are quickly and discreetly released.
as for non-undercovers who are off-duty, they can dress however they like. most large departments have grooming standards that must be adhered to when it comes to hair, fingernails and the like.