Since the author of the accepted answer does not seem to be from Sri Lanka (no offense, sir), I'd like to add a Sri Lankan answer to this.
Most of the Sri Lankans (Sinhala or Tamil speaking) can speak English to some degree. If you are in Colombo or Kandy, there is a very good chance that the person you are speaking can understand English. English is a requirement to hire for sales department in most of the super markets and other shops so go ahead and speak English. Just try to maintain a slow and clear accent.
There are 3 major "races" (although we don't really use that word) here - Sinhalese, Tamils and Muslims. Muslims usually speak both languages. Overall, Tamil and Muslim people can speak Sinhala just like other Sinhala people do. Both Tamil and Sinhala languages, however, are difficult to understand and how you pronounce the word will also make a difference.
MeNoTalk's answer is just perfect and just refer the map. However, even in the areas that the map says Tamil speaking people are a lot, you will find people who speak Sinhala fluently.
When in Sri Lanka I would like to use a few words of either Tamil or
Sinhalese with the locals.
That is great. Speak with anyone in their own language and don't be surprised if they do their best to help you or make friends with you. Everyone here is very friendly.
Are there cultural appearances that I can go from?
Yes. Tamil people, in most cases in the morning, go to their religious places. They have some dot in the forehead and Tamil women usually have white color decorations in their head (and relatively darker skin color compared to the rest).
One easy way would be to look at the sign boards of shops. If that's a tamil only board, or have the tamil version first, that's a sign and Tamils are there or many of them speak Tamil. But that's not the case everytime. I'm a Sinhalese and I go to Tamil shops and their religious places (known as "Kovil"). They do the same.
I get it wrong would anyone be offended?
Not at all. Just use your hand gestures and make them feel that you really need to speak their language. Don't forget to smile. I have seen many tourists speak a little louder which is not really necessary.
If a girls has a Mulsim scarf (I don't know the actual name), and is with her mother of father, speak with their parents and not their daughter - that's kinda offensive to approach such girl but overall, you'll be welcomed everywhere.