When my sixth grade class used to ask Ms. Simons how long our essays had to be, she'd say "Miniskirt." This, in her parlance, meant it was supposed to be long enough to cover everything important, but short enough to be interesting.
The same general principle applies to the timing of telling your boss you're pregnant. There are reasons not to do it too early, reasons not to wait too long. On balance, in most circumstances, somewhere between 14 & 20 weeks is about ideal. Here's why.
Risks of waiting too late:
--At some point, you become the elephant in the room. If you're not talking about being pregnant but it's becoming obvious, it just gets awkward.
--Your boss will have a harder time finding coverage for your position, which, though in some circumstances not your problem, does mean just more negative vibes in the air to deal with. The more time you have to figure out how maternity time coverage will work (and what the possibilities are for coming back after) the easier that process might go in some situations.
--If you're pregnant, you don't tell him/her but somehow your boss finds out and then pretends not to know, and then fires you because of your pregnancy then claims not to have known, you're screwed. It happens. If you tell them early on and then suddenly you're fired or given a harder time or otherwise treated badly, you might have more legal protection in some situations.
Risks of sharing the news the moment you know:
--Not to be TOO depressing but a lot of early pregnancies do result in miscarriage. The general recommendation on that front is to wait until 14 weeks at least (once you've heard a heartbeat and all that). If you've told your boss then something happens then you have to tell THAT news too, and it's just awkward.
--Being too forthcoming can come back to bite you in some circumstances. The moment you tell people you're pregnant, some (not all -- but some) people are going to attribute everything you forget, everything you drop, every time you trip, to your pregnancy.
--Know thyself. You may need some time to get used to the idea of being pregnant and get comfortable with that concept before making it public knowledge.
These are just some of the thoughts that should go into your decision of when to tell. How to tell them is for another day.