First, defeat Brawly at the Dewford Gym. You need the badge in order to use Flash. Then, go to the Hiker inside Granite Cave and he will give you the HM. (Thanks to Tysonyoshi for reminding me :D)
Go to the Menu which will appear at the right hand side. Then, click "Pokemon". Select the Pokemon that knows Flash, click on it and the following options will come up:
Click Flash, and the Granite Cave will light up.