Wearing underwear?

Is it ok not to wear underwear while pregnant? I wear underwear threw thr day but I hate wearing them to bed.. is that ok? I know they say you have a higher chance of infection?