Five months is the first big testosterone surge - I would be watchful of intact males around unspayed females at that point easily.
In fact, call me cautious, smart, paranoid, or whatever, but if I had a young male pup around unspayed females in season, I would separate.
I know people on this board have dogs that are well behaved or don't show interest, but I have 2 male mixes here who were hyper aware of females, their urine, etc, from a very young age and I am sure if they were around a female in heat, a breeding would have occurred - whether or not their sperm was ready prior to 5 months, I don't know, but they were ready to roll.
I'm with Jean. The rescue I foster for knows not to send me any females older than 10 weeks or so, unless they are spayed. Being a rescue, the females often get spayed at 4-6 months so thus far, I've only had one female foster and she was 6-7 months when I got her. Better safe than sorry!!
A Norwegian Forest cat breeder I spoke with some yrs ago said that sexual behavior presents earlier when intact animals are raised together. Given this, anyone with an intact male & an intact female should err on the side of extreme caution & not assume they're too young or not interested.