I've been working and diving in Panama for nearly 20 years, so here's my suggestion. First, your best bet traveling between Panama City and San Jose would be to fly. Driving in this part of the world can be tough. In addition, there are some protests going on right now in Panama and there is more than a small chance that you could encounter a road that is completely blocked by protestors.
I don't have any recommendations for Costa Rica, but I highly recommend Golden Frog Scuba in Portobelo, Panama. You have to be careful with many of the operations in Panama, they are commonly non-responsive or bit shady. I've been diving with Golden Frog for about 6 years and they are consistently reliable and honest and they can help arrange transportation to Portobelo. They are a small operation, and my buddy and I commonly end up diving with just the owner as a guide. They operate out of a small hotel, so you can stay in there if you want to do an overnight. The hotel is clean and has a nice restaurant on site as well; try the red curry! The only down side to diving on the Caribbean side of Panama is the rainy season. It's been exceptionally wet this year and that has the visibility down in the Caribbean. We've canceled a couple of dives so far this year because the viz has been bad. That's never happened before, so it's just one of those weather things. It is entirely possible that the rains could let up in the coming weeks though and the viz will improve.
Golden Frog Scuba provides excursions and certifications with PADI certified instructors and other services such as snorkeling, hiking and kayaking.
www.goldenfrogscuba.com