Many people travelling through Latin American suffer from upset stomach problems a few days after they arrive. Unfortunately, Costa Rica isn't exempt from this problem. The situation is a whole lot better than in other nations, but you might eventually experience some discomfort if you don't follow a few basic rules.
Water in the large cities and towns of Costa Rica is safe to drink. It's chlorinated and frequently tested at plants for bacteria and other contaminants. Most pipelines and treatment plants are run by Acueductos y Alcantarillados , a state-owned company. Look for the AyA logo on tanks, water meters and infrastructure in your community, which signals the water comes from one of their plants.
Rural towns often have aqueducts run by community groups, known as ASADAs. These groups work closely with Acueductos y Alcantarillados to run and monitor their quality, and in general terms also provide safe drinking water.
Some smaller towns have municipal aqueducts. These should be explored carefully: some provide excellent quality service, but a few lack maintenance and can give you trouble if you're not used to the water.
Sometimes, the water contains bacterial strains your body may not be used to. These can cause cramping, bloating or in more sensitive people diarrhea and vomiting. The symptoms pass with time, as your immune system learns to take care of the microorganisms by itself. But until that happens, you'll need to take care of the associated symptoms. Over the counter medications can greatly help while you're making the transition.
Drinking bottled water is a good way to prevent troubles from the water when you're outside the metro area. However it's more expensive, not so environmentally friendly, and won't protect you from infection by bathing in rivers or oceans, or from eating salads and raw fruits and vegetables.
The best thing you can do is ask about the water at the place where you're staying. If the water might give you trouble, they'll tell you about it. And get over the counter medications to take with you, just in case.
Like any other place, food quality can vary depending on where and when you buy. Serious food poisoning is not commonly seen in Costa Rica, as most restaurants and diners take good care to prevent unsanitary conditions.
All restaurants and establishments selling food must have a sanitary permit from the Ministry of Health, which has to be displayed in a visible location.
Just like back home, use your senses to judge your food. If the restaurant doesn't look clean, find another place. If it smells funny or doesn't taste fresh, send it back.
Chicken, pork and beef should have a clean taste: it should taste like beef, without any rancid or acrid taste. Fish and seafood should not smell, a strong fish smell is a sign that it's past the fresh stage. Rice and beans should not taste sour or rancid under any conditions.
Food here isn't much different from what you might find back home, and most rules apply. You can usually tell when something's gone bad or is getting there. If it seems that way, better to avoid it.
On the streets, you can find many vendors selling fruits, vegetables, snow cones, etc. Take a bus and you might see someone get on to sell pastries or other food. At some of the more frequented night spots, you might even see a guy outside with a grill and everything.
Avoid them. The conditions the food is prepared in, where the ingredients come from, and how long it's been sitting there are really not clear in these cases.
If you purchase raw fruits or vegetables, purchase them whole, and be sure to wash them with clean water before you eat. Avoid any fruits or vegetables that are sold on the street sliced, or out of their natural shells.