There are really two types of people when it comes to this.
The first is your close family or friends. The people who would love and support you if you had a miscarriage. Tell those folks whenever you want. But in general, wait until after 12 weeks when the risk of miscarriage is lower.