Are there specific situations where one spelling variant is recommended over another?

Solution 1:

I'm from the UK, but will use US spellings in some contexts. Programming languages generally use US spellings, the HTML center tag or the CSS color property for example, and it can be a bit jarring to write stuff like "use color to set the colour". Another issue is that spell checkers are always either US or UK, so you end up with loads of red lines on correct spellings if you use a UK spellchecker to discuss code.

Generally speaking, you can use either UK or US spellings, even when addressing one or the other audience (I've never known anyone that objected); just be consistent.

Solution 2:

Pick one and stick with it. Both are acceptable in just about any case, as long as you don't switch back and forth. The only time I could imagine it mattering is when submitting a literary or scientific piece that's required to be in a certain format.