"You got to know when to hold 'em, know when to fold 'em."

Kenny Rogers was talking about gambling -- or maybe women. (With country songs, it's sometimes hard to tell.) But his advice seems to fit investing pretty well, too. Knowing when to sell can be just as important as knowing when to buy.

Time enough for counting
Buying is often the easy part. Good investors do weeks, if not months, of homework before they buy. After doing the research, the stock is either good enough to buy, goes on your watch list, or gets discarded. You don't have to make any rash decisions.

However, a major change at the company can also trigger your impulse to sell. In these cases, it can be easy to let your emotions get the best of you -- but that doesn't mean you should sell without thinking first.

The best time to figure out when to sell is before you buy the stock in the first place. Working out which changes at the company would cause you to dump it will help you remove the rashness from your decision, should any of your worst-case scenarios suddenly arise:

  • Should you sell Apple (NASDAQ:AAPL) if Steve Jobs leaves permanently?
  • What would you do if Altria (NYSE:MO) or Duke Energy (NYSE:DUK) cut its dividend?

Planning ahead also helps you become a better investor, by encouraging you to look for more subtle changes in the company:

  • If Corning's (NYSE: GLW) gross margins start creeping down, at what point would you sell?
  • How bad would the recession have to get before you'd dump Whole Foods Market (NASDAQ:WFMI)?

Know when to walk away, know when to run
After Pfizer (NYSE:PFE) bought Wyeth (NYSE:WYE) earlier this week, I turned in my bull horns and headed into my bear cave for a siesta. In the article's comments, a reader asked: "So, Pfizer went from your best stock pick of 2009 to sell...sell....sell....in less than 30 days?"

That was a legitimate question, since I did pick Pfizer in our best stocks for 2009 series. But what looks like waffling is actually a virtue in this case, not a vice.

My investment thesis for Pfizer in 2009 was simple: The company had a $26 billion pile of cash, which value-conscious management could use to help grow earnings through well-timed licensing of drugs, and perhaps a minor acquisition or two. Pfizer also paid a whopping dividend that didn't seem in immediate jeopardy of being cut, so it was essentially paying investors to wait.

After the acquisition of Wyeth, the cash was gone, the dividend was cut, and the company's managers no longer looked like the value investors I thought they were. Changing my mind was a fairly easy decision. As long as I don't flop back anytime soon, I think I can avoid being lumped in with other mind-changing pundits.

You never count your money when you're sittin' at the table
It's important to keep in mind that selling doesn't mean you think the company will tank tomorrow; you don't have to follow up your sell order with an order to short the stock. Selling just means that you don't think the company is the best place for your hard-earned investing cash.

In fact, Motley Fool co-founder David Gardner says his sell signal is pretty simple: He sells when he finds a better investment than the one he's in right now. That might mean selling a winner or a loser, but the important thing is that you're always chasing higher returns. That's what investing is all about.

Pfizer and Duke Energy are Motley Fool Income Investor picks. Pfizer is a Motley Fool Inside Value recommendation. Whole Foods Market and Apple are Motley Fool Stock Advisor picks. The Fool owns shares of Pfizer. Try any of our Foolish newsletter services free for 30 days.

Fool contributor Brian Orelli, Ph.D., thinks there's deeper meaning in most country songs -- at least he hopes so. He doesn't own shares of any company mentioned in this article. The Fool's disclosure policy listens to techno.