Can I enter panama and Costa Rica without a visa?
Yes you can enter Panama if you have a valid passport for at least 3 months and visas from the following countries regardless of your nationality:
Source:Consulate General Of Panama London
“Those who hold a valid passport for at least 3 months and a valid visa from ONE of the following countries: USA, United Kingdom, Canada, Australia or any of the member countries of the European Union, which has been used at least one time to enter those countries, may enter the Republic of Panama by purchasing a Tourist Card, regardless of their nationality.”
You will just need to buy a tourist card upon arrival. The tourist card is purchased upon arrival at the Panamanian airport and it has a cost of thirty dollars and zero cents (USD $30.00).
The tourist card is valid for 30 days, renewable at the Office of Migration for an extra period of 60 days.
You can also enter Costa Rica on your 5 years valid USA visa.
Source: Embassy Of Costa Rica Washington
"Citizens of other nationalities do not need a tourist visa to enter Costa Rica if they have a tourist visa, a visa for crew or a business visa (multiple entry) from United States of America, Canada, Japan, Schengen Visa and/ or any country of the European Union . Note: Such visa must be stamped in the passport and be valid for at least 1 day (The length of stay may not be greater than the validity of the visa and may not exceed 30 days) or 6 months (Japan) from the day you enter Costa Rica."
Therefore you can simply enter Panama and Costa Rica on a valid USA visa provided you may stay in Panama for 30 days and can be extended for extra period of 60 days. Whereas in Costa Rica the length of stay is limited to 30 days only.