I assume you're talking about a complication such as a botched circumcision - which happens.
I would tell them as soon as they were old enough to understand. Better to tell them early on rather than have them waiting for a first period that's never going to come.
As for girls... I've only heard of that happening in hermaphrodites. In which case, if they were by all outward appearances a boy, they're going to figure out something is up when they're rushed to the hospital when the aforementioned menstrual cycle arrives and has to be dealt with surgically.