Gokarna is about 480kms from Bangalore and can be easily accessed by various modes.
How to reach?
There are many direct private sleeper buses from Bangalore to Gokarna. You can book them from here. It takes about 8-9 hours by bus.
This option can be used if you're travelling not just from Bangalore, but also from Mumbai. You can book your tickets here.
This is the best option as it gives you complete flexibility to enjoy the coastal Karnataka's landscapes and nature on your drive.
Where to stay?
If you're on a budget trip and looking to meet other travellers then there are hostels which you can consider. Zostel and Trippr are really good and not very heavy on your pocket.