OK, so this is about writing an essay as part of an exam. But despite that, discussions about essay writing not within an exam setting also use this idea of off topic. What matters is the term essay, not the term exam or examination to judge whether this works or not in an essay context.
Here is just one example from the Internet that discusses the idea of staying on topic and going off topic when writing an essay. (Sorry, but seems so babyish to my ear but I guess it needed posting to show the usage.)
Staying on Task and Addressing Your Essay Topic
Have you ever composed a beautifully written (brilliantly thought out)
essay only to receive a disappointingly low score because you didn’t
address the topic? No matter how great your essay is, you’ll never
receive a high grade if you don’t address the topic and stick to it.
On most standardized tests, for example, writing an essay that is off
topic will earn you a zero.
Straying off topic happens to the best of us, but there are plenty of
strategies you can use to avoid this common pitfall. [Bolding mine]
The word off topic appears many times in that article:
- avoid writing an off-topic essay
- off-topic ideas
- look for [and remove] any off-topic information
addressing a topic in an essay
- The French term hors sujet means off topic.
And this term is used in other English-speaking countries as well.
Another example, from Australia:
And then England: Imperial College London
When answering essay questions, focus on answering the question. It’s
easy to go off-topic if you don’t plan ahead, so prepare a structure
for your answer in advance. You might find it helpful to plan all your
answers at the start of the exam, while your mind is fresh.
sitting examinations
[off topic takes a hyphen when it precedes a noun]