We research all brands listed and may earn a fee from our partners. Research and financial considerations may influence how brands are displayed. Not all brands are included. Learn more.

Money is not a client of any investment adviser featured on this page. The information provided on this page is for educational purposes only and is not intended as investment advice. Money does not offer advisory services.

Most workers have learned their lesson about holding a lot of company stock, although some of them did it the hard way. Just ask anyone who had a pile of Lehman Bros. shares, or any bank for that matter, in 2008. They may have lost almost everything in short order.

Yet employers keep enticing the rank and file with 401(k) matches in company shares and employee stock purchase plans. These can be attractive benefits. But they must be managed. In general, you should take advantage of the programs to get company shares on the cheap—but then quickly sell before you wind up with too many assets tied to your employer. Remember, your income is already tied to the health of your workplace.

Company shares as the matching component in a 401(k) plan fell out of favor nearly two decades ago. After the Internet bust of 2000-2001, many companies began freeing up workers to sell any matching employer shares quickly. And more companies began offering matching contributions in cash, which is invested in employees' 401(k) portfolios. Workers themselves have lightened up on company shares as a 401(k) investment option. Only 7% of 401(k) accounts are invested in company shares today, which is less than half the level of 1999, reports the Employee Benefit Research Institute.

The record is less encouraging with employee stock purchase plans, known as ESPPs. In a new report, Fidelity Investments found that less than half of workers in such plans sell their shares within two years. Even that window is too long. Think again about those bank stocks in 2007. Bank of America, which survived, saw its stock tumble from $54 to $3 in about two years during the financial crisis.

The best part of company shares is that they may come essentially free as part of a 401(k) match or at a discount of up to 15% in an ESPP. The ESPP discount represents an instant, riskless gain if you sell right away. Yet only 6% of employees who sell all their ESPP shares do so within 10 days, Fidelity found. As a rule of thumb, no more than 5% to 10% of your investing portfolio should be invested in company shares.

Calculator: How should I allocate my assets?

Stock purchase plans can help you build wealth on the cheap even as they foster a disciplined approach to regular saving. The best time to buy shares is during what’s known as the “look back” window, an extended offering period when the price is typically lowest. Company shares acquired through an ESPP have another benefit: they are easy to sell and may serve as a ready emergency reserve. So ESPPs are nothing to sneeze at.

Yet many participants find these shares difficult to part with because they typically must be held one to two years to qualify for capital gains tax treatment—that means you will pay a top rate of 15% on your profits (unless you're a very high earner). But a lot can go wrong in that holding period. Meanwhile, those most vulnerable are the least likely to sell their ESPP shares. Workers under 30 are far more likely to unload all their shares within two years than workers over 60, Fidelity found. Company stock may be a sweet deal—but only if you manage it the right way.