If you look around at the "gender determination ultrasound" places (which, drives me crazy, cause you find out the physical sex, not gender. but w/e ) they'll say 16 weeks is the minimum. Mostly because before then, things still REALLY look the same. Just google some images of the differences in a boy and girl at 15 weeks (several pictures, not just one or two as all babies form at different rates) you'll see how similar they are.
Short answer: 16 weeks.