As indicated by algarveholidayer the train from Portimão Station is a good option.
1) Train
From Praia da Rocha you would need to get a local Vai-Vem shuttle bus via Largo de Dique (Lines 5 & 6) from Praia da Rocha to Portimão Station.
If early in the morning you may need to take a cab the 15 minute drive to the station.
See Cubsur's excellent page on this here:
thomasallen.home.sapo.pt/travel/011.htm
From Portimão you would need to get a local train to Tunes Junction - about 35 minutes.
At Tunes you would connect with either one of the twice daily Alfa-Pendular Services that run through to Porto via Lisbon or get one of the Inter-City Services to Lisbon Gare Oriente Station where you would connect with a Lisbon to Porto Train.
As Algarveholidayer indicated timetable info is available on the www.cp.pt site.
You can find a direct link to the pdf version of the current CP timetable for this route on my blog:
http://barlaventostravelblog.blogspot.com
Scroll down on the right and you will find at panel entitled:
»» Algarve & Portugal - Travel Transport Links
In this panel look for:
>>>Portuguese Railways - 2008 - Lisbon - Algarve Faro/Lagos Timetable
>>>Porto - Lisbon - Porto Train Timetable
Click on each to download the timetables in pdf form.
You are looking at a minimum of 6,25 hours for the services using the fast Alpha Pendular from Tunes.
2) Bus
If you also look in the panel on my blog entitled
»» Algarve & Portugal - Travel Transport Links
You will also find two links entitled:
# RENEX Bus Service - Lisbon to Algarve timetable (pdf)
# RENEX Bus Service - Lisbon to Porto timetable (pdf)
Renex (www.renex.pt) operate seven daily bus services from Praia da Rocha to Lisbon Gare de Oriente Coach Station.
Renex also operate connecting buses to from Lisbon Gare de Oriente Coach Station to Porto.
The minimum transit time on this route is about 7.5 hours.