By train
Gokarna is connected by rail from Karwar, Ankola, Hubli, Mangalore, Kumta and Margao. The Konkan Railway (http://www.konkanrailway.com/) passes through Gokarna - Kumta 35 km and Ankola 20 km are the nearest major railway stations. However, some like Matsyagandha expressMangalore-Mumbai via Madgaon do stopover at Gokarna. The Karnataka State Road Transport Corporation (http://www.ksrtc.in/) operates buses from these places to Gokarna. Gokarna's train station is actually about 8 kilometers away from the town, taxis usually ask for around Rs 250 whereas Rickshaws should be in the Rs 120-200 range unless you arrive at nighttime during the monsoon. If you want to save some money, just take a right at the road right in front of the train station. Once you hit the main road, there's a bus stop where you can catch a bus that will take you into Gokarna for Rs 10.
By bus
From Bangalore, depending on the day of travel, there are anywhere from 1-4 buses operating. It is a 12 hour overnight journey from Bangalore to Gokarna. the experience taking the overnight sleeper was described as "being driven in a bouncy castle driven by the wicked witch of the west" - beware. Till now there is no direct rail transport from Bangalore to Gokarna. Private buses also operate to/from Hampi/Hospet. You can book online ticket to gokarna from (http://www.redbus.in) or any one of the operator's websites. National highway 17 is about 9 km from the town. The Bangalore - Goa highway passes through Ankola which is 20 km from the town. Coming down to Kumta is good option because one can easily catch buses to different places especially Mangalore as it is well connected.
If arriving from Goa, you can take a local bus from Madgaon or Canacona to Karwar, then catch another bus to Gokarna.