I told my boss immediately, as once you formally tell your employer they are bound by different rules governing your care, and you have more protection. For example, if you take time off for scans, antenatal appts they must give you this time off as paid. If they know you are pg, you will not have to bunk off or take AL or make time up.
Also, pg related sickness cannot count towards normal sickness, and you cannot be disciplined for extended amounts of leave if it is related to pg, so if like me you have just been given a few days off for pg related exhaustion, it does not count as sickness for HR purposes.
You have to have a risk assessment, which means if there are any risks at work, either physical, emotional, stress related that can impact on your pg they can be identified and managed accordingly, for example, if you are required to work late evenings but you cannot physically manage it, this can be adjusted, if you are required to lift heavy objects this will be addressed, that kind of thing.
And finally, if things go wrong, you are entitled to a period of special leave absence.
Until you tell your employer, you are not covered by any of this. You can request that only your line manager/one HR person is informed until you feel ready for your colleagues to know, otherwise they are breaking the DPA.