Aside from the fact that she might die in the next year or two (and she doesn't want to die with her virginity), Hermione is aware that if she is captured during the war, things might go badly for her. She's not stupid. She knows what happens to female prisoners. And if that's how she loses her virginity... well, she won't let it happen like that.