Yes. Al major credit cards are accepted across the country, but not in every shop and stand. Lots of small shops and restaurants prefer accepting only cash, and so there are some destinations where you’ll only be able to use your credit/debit card at the supermarket or at the ATM, to retrieve cash. For example, Santa Teresa and Puerto Viejo tend to be cash-only towns, but there is an ATM nearby for you to have it at hand.
To make sure everything will work well during your visit to Costa Rica, notify your bank before your trip so that they don’t treat your transactions as suspicious for being in another country and block your account. Also inform yourself whether or not your credit card will charge you a percentage for purchases in other countries (some credit card companies charge 1 or 2%!).