Let's take an English-speaking Norwegian and a Norwegian-speaking Englishman as an example. What are the most and least influential variables that influence how they will communicate outside of a planned language exchange? Does it matter more which country they are in or who is more fluent in their second language? What about other factors such as social context, need for language practice and the presence of monolingual speakers in the group?
As it happens, I work in Norway at an international workplace.
The levels of fluency of the involved people, and the importance of the discussion, are what matter the most. Higher fluence gives more options, while important discussions are likely to be held in a language that maximizes the skill of the least proficient language user. If the people do not know each other, then assumptions about their language skills also matter - if someone looks "Norwegian" enough, then they are likely to be addressed in Norwegian, where as "foreign"-looking people are more likely to be addressed in English. (These intuitions and guesses go often wrong, as appearance is a poor predictor of language proficiency. I guess this tendency will die out in a couple of years or decades.)
People usually address me in Norwegian if I use Norwegian, or English if I use that, or one or the other if they hear me speak Finnish (to a third person).
Typically, it is seen as impolite to speak in a language not everyone understands. This might change if the person has said it is okay to speak in the language or that they are learning it, but it also might not.
In my workplace, Scandinavians speak their own language, Germans and Austrians speak Norwegian (and German to each other), Finns speak Norwegian, English or Swedish (and Finnish to each other), and other groups use and are spoken to in English.
Context certainly matters, as you mentioned. For example, do these two people know each other?
1.) It will matter if one person speaks their L2 at a notably higher level than the other (say C2 English-speaking Norwegian vs a B1 Norwegian-speaking Englishman). If their combined English is way better, then they will probably default to English, probably no matter which country they are in.
2.) Did they randomly meet on the street? If so, then they will likely default to the language of the country they are in, assuming the foreigner can speak the local language well enough. But if they already know each other, and their L2s are at the same level, then it will likely depend which country they are in.
3.) They may simply agree to speak their L1 to each other so the other can practice listening to their L2. Or vice versa.
4.) Maybe they'll have a mixed-language conversation. People can switch things up on a sentence-by-sentence or paragraph-by-paragraph basis, if they both feel like speaking both languages, or if certain expression work better in certain languages.