I think it's most helpful to find an answer to it when it DOES come in my mind.
To do something every day for years, to pick up a drink because I'm angry, sad, disappointed, tired, bored, happy, celebrating - I created a habit and a habitual thought process. That doesn't just magically disappear, there are associations between alcohol and emotions.
I've been sober four and a half years. I have no intention of drinking again, but in the early days I thought about it quite a bit - it was a habitual thought pattern.
In time I thought about it less and less. Today if it pops in my head it's usually in response to some situation like a super hot day at a specific restaurant or something that reminds me of a past drinking time.
It's okay that it pops up, I just say, "Hm. A drinking thought. I don't drink," and it goes away. That wasn't very easy in the first few months - now it's really easy.