Many women wait until the first trimester passes to inform even their relatives, and therefore definitely the people they work with and their employers. The odds of having a miscarriage go down significantly after the first trimester, and it is more than understandable that you haven't the slightest wish of informing everyone you are around every day that you lost a baby, after first telling them you were pregnant. Still, there are a few things to consider when it comes to the best timing of letting your employer and co-workers know you are expecting.
The first trimester is a time filled with fatigue and often morning sickness. It is definitely a time during which support is welcome! You can hardly expect your employer to understand you turning up late regularly all of a sudden, or running to the rest room every five minutes, if they do not know that you are pregnant. Therefore, there is certainly an argument for telling your employer about your pregnancy as soon as you know. If you wait until the last moment, when you are already starting to show, your employer might feel angry because you made arranging for a replacement while you are on maternity leave more difficult than it had been if you had told them earlier. Furthermore, you will probably need to be absent for prenatal appointments at least a few times, and if you tell your employer sooner rather than later, you won't need to take annual leave for your prenatal appointments.
If you expect that your employer will not react positively to your pregnancy, waiting longer does make sense. Announcing your pregnancy around the 20 week mark, for instance, can go a long way in showing them that your productively has not been impacted negatively by the fact that you are expecting a baby. If your job is target-focused, a successful result to a project might also be a favorable time to make the big announcement. But, employers that are likely to react in a positive manner do benefit from hearing your news earlier on. It's your call, at the end of the day!