After the Team Magma/Aqua leader reawakens Groudon/Kyogre, you go through Route 126 to reach Sootopolis City, home of the Cave of Origin.
Get Ready to Face Groudon/Kyogre
When you arrive, Surf northeast and rest at the Pokémon Center if you need to.
Then Surf to the west side of town. There is a path along the east side of the Poké Mart that goes north. Go up that path, and continue going north until you see Steven to the right. Go over to him and watch the cutscene. In Omega Ruby, you will get the Magma Suit. In Alpha Sapphire, you will get the Aqua Suit.
After the scene, you will be able to enter the Cave of Origin. At the bottom of the cave, you will encounter Groudon in Omega Ruby, or Kyogre in Alpha Sapphire. You can try to catch the pokémon, but because it is a legendary pokémon, most poké balls will have a very low chance of success. You could throw the Master Ball at it (assuming you got it from the Team Magma/Aqua hideout), but you might want to save the Master Ball for another time.
If you don't want to use the Master Ball, you should bring a lot of other types of poké balls with you. You should also plan to use False Swipe or Hold Back to reduce the pokémon's HP to 1, and you should bring a pokémon that can cause Sleep or Freeze. Doing this will increase the likelihood of catching the legendary pokémon.
Types of Poké Balls to Bring
The following paragraphs assume that you have reduced the legendary pokémon's HP to 1 and have inflicted Sleep or Freeze on it.
Timer Balls, which you can buy in Rustboro City after you have talked to the Scientist who is standing outside of Rusturf Tunnel, will have about a 15% chance of catching the legendary pokémon after 30 turns have passed.
Dusk Balls, which you can buy in Fallarbor Town, will give you about a 13% chance of catching the pokémon. In addition, if you are playing Alpha Sapphire, Dive Balls, also available in Fallarbor, give you the same chance.
As a last resort, have a lot of Ultra Balls with you. They will have about an 11% chance of working.
Enter the Cave
If you feel that you are prepared, enter the Cave of Origin.