In all likelihood, there's no company you know better than the one you work for. That can make buying shares of your employer's stock seem like the perfect investment, especially when you're enthusiastic and optimistic about your company's future prospects.

Often, however, employees make the mistake of putting far too much of their money into their employer's shares. Sometimes, that big gamble pays off with outsized gains -- but if things go badly, then it can put your entire retirement at risk.

Chesa-peaked
Employees at Chesapeake Energy (NYSE: CHK) are just the latest group of workers to feel the pain that a big drop in share prices can bring. Figures from Brightscope showed that 48% of its 401(k) plan was invested in company stock at the end of 2010, while Reuters reported a more recent 38% allocation to employer-stock. As Chesapeake stock has plunged following multiple controversies over CEO Aubrey McClendon's actions, workers have seen a huge chunk of their retirement nest eggs go up in smoke.

Moreover, Chesapeake does something that most companies have moved away from: It pays matching contributions in the form of stock rather than cash. That takes away some flexibility for workers to manage their own portfolios, and some newer employees aren't even allowed to sell those matching shares.

Big bets on company stock
Chesapeake isn't the only company in which workers have big allocations to employer stock in their retirement accounts. Back at the time of the Gulf oil spill, BP (NYSE: BP) workers had almost a third of their money in company stock. At Lowe's (NYSE: LOW) a whopping 56% of money in the company's 401(k) was invested in employer stock according to the latest available information from Brightscope. A General Electric (NYSE: GE) plan has 41% allocated to GE stock.

But for the most part, both workers and companies have gotten the message. After Ford (NYSE: F) and a host of other companies got sued by workers after big drops in their 401(k) balances, employers started putting limits on how much stock employees could have among their 401(k) investments.

Why it's risky
Anytime you put too much of your money in a single investment, you run the risk of substantial losses. Diversification may leave you with less upside if your employer's stock does well, but it also protects you from the complete losses that workers at places like Enron suffered when their companies went out of business.

The argument against keeping all your eggs in one basket is even more appropriate when you're talking about employer stock. If bad news hits your company, then it won't just hit the stock price -- it could also put your job in danger. If you get laid off, then the double-hit from losing your paycheck and seeing your retirement balance fall sharply is especially hard to work through.

Everything in moderation
I've long believed that there is a place in your portfolio for some company stock. Some employers offer discounts for buying shares in retirement plans, and taking advantage of those discounts can make up for some of the risk involved.

The key, though, is not to get greedy. When your company is doing well, it's tempting to let your employer stock allocation rise. But when things are going perfectly, it leaves investors most exposed to unexpected bad news that can send your stock plunging in a hurry -- before you can do anything to protect yourself.

If your job offers you employer stock, tread carefully. Keeping a small portion of your investments -- between 5% and 10% is a common rule of thumb -- may be fine, but any more than that can leave you taking on too much risk.

If you need better ideas for your retirement accounts than employer stock, we've got something for you to take a look at. The Motley Fool's special report on retirement gives you tips on planning for retirement and beyond, with three smart stock names to consider adding to your IRA or other retirement account. It's free, so just click here and get your copy right now.