You need to defeat Team Galactic first. First, go to Lake Acuity (near Snowpoint City). You see your rival who just got defeated by one of the commanders. After that, go to Veilstone City. Talk to the Galactic Grunt outside Galactic's Veilstone Building. He will drop a key. Take the key and go to the building where you found the HM for Fly. Use it on the door and you can enter the basement of the Headquarters. Go through the headquarters (you will have to find another key to get to parts of the building) work your way to the boss. Defeat him and go free the Pokemon of the lakes (note: he gives you a Master Ball). After freeing the Pokemon, you will need to follow him up Mt. Cornett and defeat him once again. This is the time you can catch Palkia. Once all that is done, you can go the Sunyshore City, home of the 8th Gym Badge.