There really isn’t any general principle besides doing your research, which is a good plan when traveling anyway.
Travel guidebooks usually include a section with general practical and cultural advice about your destination. That may include things like standards of dress, gestures to avoid (there is wide variation here, including some obscene gestures in some cultures that are benign in others), sensitive subjects (there are countries where it may be against the law or just ill-advised to say negative things about the local monarch or religion, and discretion is always a good idea before discussing politics), and customs (there may be particular practices around things like meals, greetings, or gift giving).
A search on “(name of country) etiquette” is usually a quick way to produce this kind of information.
There may be more specialized advice for some situations, such as websites and books with specific cultural information on doing business in certain countries. Certain types of facilities, such as pools or saunas for example, may come with their own local etiquette around things like bathing and clothing, so it’s worth researching that if you plan to visit.
All that said, and particularly living in a more global world today, the vast majority of people you meet will understand that you’re a visitor unfamiliar with local customs, even more so if they’re in the tourism industry, and that if you act with good intentions, may be more amused than offended if you haven’t mastered every cultural detail. But the point of traveling is to make positive connections, so doing your best to learn about the local culture and use at least a few pleasantries in the local language can go a long way.
And if you’re not sure about something, it’s usually best to simply ask.