The consensus online seems to be 'never ever ever.' I want to complicate that a little.
The default is right: don't tell your manager you're searching. In most cases there's no upside. They can't keep it secret, it affects how they allocate stretch work and sponsorship, and at some companies it triggers an involuntary exit faster than anything you do in an interview. The risk-reward is bad.
But I've seen three cases where telling the manager worked out:
Case 1: The manager already knew. You've been disengaged, turning down stretch work, taking more PTO, leaving earlier. If a perceptive manager can read the room, they already know or strongly suspect. In that case, sometimes an honest conversation unlocks something real. Counteroffers, different role scope, a genuine 'let me fix what's broken' conversation. Not common, but not mythical.
Case 2: You're searching because of a solvable problem. If you're leaving because of the commute and the company is announcing a remote policy next month. If you're leaving because you want to work on a different product area and there's an internal open role. If the reason you're looking is something your manager could actually address, telling them first costs you nothing if the answer is no and might get you what you want.
Case 3: The relationship is unusually strong and you're planning an internal move. I told my manager at a previous company before I applied for an internal role on another team. She appreciated it, helped me prep for the internal interview, and wrote the best reference I've ever gotten. But that's a once-in-a-career kind of trust.
The tell for whether you're in one of those cases: do you actually trust this person, and is there a plausible scenario where the conversation leads somewhere better than where you currently are? If the answer to both is yes, maybe. If not: update the resume quietly and stay professional until you've signed somewhere.
The worst outcome is telling them prematurely and getting managed out before you have an offer. I've seen it happen twice in person.