You can find Costa Rican coffee in many places across the country. The easiest is the local supermarket but it will not be that fresh since that bags have been sitting there for weeks just like in the U.S. You can try to tourist shops such as the ones in the airport but expect to pay premium prices and it also is not that fresh.
The best place to buy coffee fresh roasted coffee in San Jose, Costa Rica is also one of the cheapest and entails somewhat of an adventure to the what real Costa Rica is all about.
Take a trip to downtown San Jose and go the the Mercado Central (Central Market). Everyone knows where is is located but the address if you need it is Avenidas Central y 1, Calles 6 y 8. It is an indoor flea market where you can find fresh meats, cheese, leather goods, spices, souvenirs and of course fresh roasted coffee. This is the best place where to buy coffee in Costa Rica. You can eat a decent lunch of breakfast there as well. Understand that this is a flea market and there are no luxuries.
Near the northwest corner inside of the Mercado Central is a coffee roaster with a store front. They fresh roast coffee right there and pack it for you for taking it back to the state. Try the Costa Rica Peaberry Coffee which is the one of the best coffees in the world in my opinion which in Spanish is called Caracolillo. I suggest you load up with as many kilos as you can stuff in your suit case and of course only get whole bean to preserve the freshness.
Their phone number is (506 ) 2222-1769. The only precaution for the Mercado Central is that you do not wear your fine jewelry and dress down so that you do not become a target of any thieves. It also is not a custom for males to wear shorts and if you do your are shouting out TOURIST!