Thank you for replying.
"Does that happen in TextEdit, Mail, and Safari?"
Unfortunately it's not consistent, which makes it harder to pin down. For example when I wrote the original post (in Safari) the input would change every time I clicked in another part of the text, but today it isn't happening.
”You're not accidentally hitting the shortcut for switching layouts, command pllus space?”
I'm using a Japanese keyboard which has specialised keys to the left and right of the space bar to switch to roman and Japanese characters respectively. I've been using Macs with this kind of keyboard for about twenty years but this problem has only arisen recently.
When I open the above programs or open a new window in any of them the input switches to Japanese nearly every time. Also in the finder, as I mentioned above, if I click in the name of a file or folder the language immediately swaps to Japanese even if the existing text is roman. If I press the roman key to reset it but then click in another file/folder icon's name, it will again change to Japanese.
Incidentally I have a back-up hard drive with the same version of the OS, but that doesn't have this problem.