The first part of any hike, no matter the distance, is getting to the trailhead.
The northern terminus for the Oregon Coast Trail is located at the South Jetty of the Columbia River in Fort Stevens State Park. For most people planning a thru hike this will be your starting point.
Getting there via public transportation isn't that hard if you time it right. There is actually a bus that drops you off at the entrance to the park and from there it is a quarter mile road walk to the parks registration office which luckily is also very close to the Hiker/Biker camp.
On my first OCT thru hike the original plan was to use public transportation to get me to the trailhead. As it turned out I was lucky enough to have a trail angel from the Pacific Crest Trail offer to pick me up at Portland Airport and deliver me to the South Jetty.
Not everyone will be so lucky.
From Portland International Airport (PDX) it is easy enough to catch the MAX Red Line, also known as the Airport MAX, which is a light rail line, into the city.
From downtown Portland it is easy enough to catch the NorthWest POINT bus to Astoria. The NorthWest POINT provides daily bus service and leaves twice a day, but in order to connect with a bus going to Fort Stevens you'll need to catch the first bus of the day.
From Portland the NorthWest POINT bus runs into Cannon Beach then north along the coast through Seaside, Gearhart and then into Warrenton where you'll need to disembark to catch the local bus to Fort Stevens.
Of course, you could get off the bus at Cannon Beach to hop on the Oregon Coast Trail, and in fact the hike north towards Astoria is a great way to experience the trail over a short one or two night hiking trip.
Local bus services are provided by Sunset Empire Transportation. They have the Connector Columbia and the 10 Red Cedar bus routes that can get you there.
There is also the option of getting off the NorthWest POINT in Gearhart and simply walking north along the beach into Fort Stevens. Simply turn right at the Wreck of the Peter Iredale and follow the paved road to the Park office.
For some people this will be easier than catching a local connector bus to get to the northern terminus, but it will mean duplicating miles on the return trip.
The NW Connector website is a newer, up to date resource for getting around NorthWest Oregon via local buses, and is invaluable for hikers trying to get to various parts of the trail.
If you happen to be coming into Oregon from the north, as in Washington state, then Astoria is a likely beginning point for making your way to the trail.
Sunset Empire Transportation Services operates the Connector Columbia bus which leaves from the Astoria Transit Center and has a stop at Fort Stevens and the KAO Campground across the street. This bus currently runs three times a day during the week and twice a day on the weekends, and costs $3.
Just be sure to tell the bus driver that you want to be dropped off at the KOA Camp store, do not simply say Fort Stevens as the first state park stop will put you miles away from the campground.
Salem is perhaps the least likely place from which you would be coming from to get to the trail since you'd most likely have to go through Portland anyway.
If you do not want to go directly to the Oregon Coast Trails terminus but simply want to hike some beautiful coastline then there is a very cheap bus out of Salem that takes you directly into Lincoln City. It is called the Lincoln City-Salem Bus.
However, that bus only runs on the weekends. (Which may have changed, check the NW Connector website link above for a current schedule.)
During the week there is another, more expensive, bus that brings you into Newport operating out of the Salem Amtrak station. From the bus stop in Newport it is a short walk, for a hiker, into South Beach State Park.