The only situation I can see this as being acceptable is if the child is born with both male and female anatomy (rare, but it does happen). In that case, I think they sort of have to choose, but in any other case I think it's wrong.
It's like 'designer babies' where you can pay loads of money and select physical traits (such as eye colour and hair colour) including gender, I believe, and then scientists do some genetics-sciencey-thing and that's the child you end up with (most of the time - it's obviously not 100% accurate).
I personally disagree with this, so I would say that it's wrong for parents to choose the gender of their child unless it is under extreme circumstances.