The answer is that the ego always remains a part of us; it never goes away. Even the Buddha was tempted frequently by his ego in the form of Mara, and he stated, speaking of himself, that “a Perfect One’s feelings of pleasure, pain or equanimity are known to him; his perceptions are known to him; his thoughts are known to him.” The difference is that he, as an fully enlightened one, was always aware of them as they arose, was aware of them presenting themselves, and watched as they subsided, not having engaged them.
When one begins to walk the path, one has no awareness of ones feelings, perceptions, or thoughts. That is to say that one does not observe them, one has no distance from them, they and you are one.
But as one walks the path, and one begins through meditation to understand the illusory nature of all things, the dependent origin of all things, and the impermanence of all things, and begins to train oneself to observe yourself and everything around you without the intervention of thought, one begins slowly to become aware of your feelings, perceptions, and thoughts in the sense of being able to observe them for what they are. Initially one isn’t sufficiently aware to see them as they arise and only after the fact, during meditation, is one aware what has happened and has a teachable moment. But as the years go by and your practice deepens, your awareness and your ability to observe increases.
Think of there being a sliding dial representing the balance between your ego habit-energies and your true Buddha nature. In the beginning, the dial is all the way to the left ... your true Buddha nature is completely obscured by your ego and learned experience and you are not aware of anything. Then as you walk the path the dial slowly moves to the right ... you begin to become more discerning of your feelings, perceptions, and thoughts and the difference between what your learned experience, your ego, is telling you and what your true Buddha nature is saying to you.
It is a very slow, incremental process for most of us. In the beginning, even on the occasions when we are aware, we often don’t have the strength to deny our ego habit-energies what they want. As your practice deepens, however, one becomes both more aware and one begins to have the strength provided by your true Buddha nature to say, “no,” to your ego just as the Buddha said, “no,” to Mara. To be aware of your ego habit-energies arising and just let them subside.
But until one becomes fully enlightened one is not completely free of one’s ego. Even individuals who have reached the initial stages of enlightenment, such as the stream-enterer, are still subject to aspects of their ego habit-energies. That is why even teachers as advanced as Pima Chodron freely admit to their being subject on occasion to feelings of aggression and other aspects of their ego. It’s not a failing, although as Pima says it feels embarrassing. Here all these people come to her for teaching and wisdom, and she feels, for example, aggression towards her granddaughter after spending the day with her!
We are all human. To live is to be subject to the pulls of our ego. To walk the path is to slowly free oneself from that pull and follow the voice of your true Buddha nature. Even if one never reaches full enlightenment, the awareness we obtain by practicing the wisdom of the Buddha dharma improves the quality of our lives immeasurably, incrementally freeing us from our suffering.