Specifically, you encounter them before entering the Mt. Ember cave.
Here's a breakdown:
1. Defeat Blaine, the Cinnabar Island Gym Leader.
2. Proceed to Mt. Ember.
3. Team Rocket Grunts will challenge you before entering the cave.
They'll be blocking the path, so defeating them is necessary to progress through the mountain.