Avoiding letting a boss know you are looking for a new job until you have an offer in the bag is generally your best course of action. However, word may slip out if a co-worker lets on or the boss overhears you sharing the news. If your manager confronts you about your job search, your best approach is strategic honesty.
Keep Your Options Open
Your reaction to this situation depends somewhat on the culture and your relationship with the boss. If your manager is unhappy as well, you can likely get away being a bit more upfront. However, if the manager doesn't want to see you go, your smart play is often to keep your options open. Of course, you might explore other options without totally committing to walking away. If you have a good rapport with the boss, you can simply explain that you learned about a good opportunity, but you are just exploring options. Some employers may offer to up your compensation if they want to keep you.
Tell the Truth
The worst thing you can do if your boss learns the truth is lie to him, according to a December 2012 "Forbes" article. You don't necessarily have to reveal everything, but you don't want to say something untrue and risk losing all good will with the manager. If you say "No, I'm not looking," the manager may know you are fibbing. If you hope to maintain rapport in case a new opportunity doesn't work out, or if you need a positive reference for the new job, don't lie.
Develop a Strategy
Most of what you say and do as a job candidate or employee should include a combination of honesty and strategy. You don't want to say "I hate this job, and I want something else." This message essentially ruins any hopes at salvaging your job and relationship with co-workers if the new job doesn't work out. Instead, you could point out concerns about job security and keeping your options open. You could also simply point out that you periodically explore the market just to see whether your skills and experiences qualify you for certain types of positions. This point could spark a conversation about potential promotions.
In the worst-case scenario, the boss doesn't like you and would likely look for excuses to get rid of you. If you see nothing good coming from this situation, you should expedite your search while trying to walk a fine line at work. Some managers won't terminate you just for searching because of fears of discrimination allegations or unemployment claims. If the boss knows, at least you don't have the stress of trying to keep your secret.