Distinguishing male and female in your colony is an important part to better estimate your yield, and to determine what steps you need to take to maximize your production. For instance, in a well caged colony even when all the pupae were from the same day of harvest, the hatching time will still different in days, especially during winter times they will have a wider hatching window thanks for the low temperature. When most of the flies have done mating and ovipositioning, they will start dying, and your colony starts to shrink. Just by looking at the rest of the flies, estimating the male and female ratio, you will know what to do. If it's male dominate situation you should remove the colony and start a new one right away, otherwise you will end up with a empty larvae bin for about two weeks, because no eggs were being produced during that time. If it's a female dominate situation, you might want to wait for another few days to see more eggs.The sex of the black soldier fly can only be determined at their adult stage, which mean the earliest point to distinguish male and female is the time they hatch. The traits of each sex are well distinguished, very easy to tell.
The female black soldier fly's tail end up with a scissor shaped structure. It's their sexual organ for mating and for ovipositioning. When the female pull their tail out it means they are ready to mating, and the males will see this as a signal to initiate the mating, if it's able to see, and this is probably why light source is so important for successful mating.
As you see here, the male black soldier fly's tail ends up with a plate-like structure. If you look close it looks like an open flower.
When mating, the female and male line up on opposite side, with tails connected. The way they are connected is that the male's flower-liked tail grabs and sucks female's tail in. If you look close to the male's belly, which is generally transparent, you will see liquid flowing from the chest part toward the tails. Not sure what that is, but possibly is the sperm.