What stage does the baby determine the sex he/she is?

Many people have said your baby isn't a boy or girl yet, how many weeks is it at the point of its deffo a boy or girl even if you can't see there bits