Normally your obgyn will schedule your first ultrasound around week 20 of pregnancy. By this time the outter reproductive tissues are well formed in the fetus.
While it is possible in some cases to tell the sex of the baby before then, there is also a higher level of error. Due to a spotting incident, and an ovarian cyst, I had an ultrasound when I was about 15 weeks along. The technician said that it looked like a girl, but not to take that as a final determination, because it was still a little early to tell. At my ultrasound when I was 21 weeks it did indeed turn out to be a girl. However, I know of many people who were told there baby was on sex, only to be surprised when it was born.
Typically in a fetus, the gonads or ovaries don't even start to fully form until around week 16. Then the gonads in a boy don't even begin to drop to the outside until around week 28. So if you do have a boy you will only see its penis.
It really is interesting how the reproductive tissues form. Every fetus starts off with a tiny little nub and two flaps of skin between their legs. The sperm that fertilized the egg held chromosones to determine the sex. The chromosones then determine which hormone there is more of, estrogen for girls, or testosterone for boys.
If the fetus is to become a girl, the higher level of estrogen hormones tells the little nub to become her clitoris, while the two flaps of skin become her outter labia. If the fetus is to become a boy, then the higher levels of testosterone tell little nub to grow to become the penis, and the two flaps of skin become the sacks that hold the testicles.