Tell me please if I have to use the indefinite article before #nine in the following context.
On the scale of 1 to 10, how strong was the pain of having your tooth drilled. Well it was (a) nine.
If I need to use a there, could you explain why?
In this case, the article is optional.
The response is idiomatic both with and without the a. The choice might depend on exactly what's in the respondent's mind when s/he answers.
If the respondent imagines choosing a number from the numbers presented, the answer is likely to be a nine. Similarly a contestant in a TV quiz might choose the (number) nine as the question to answer.
On the other hand, if the respondent simply thinks about the scale of pain, responses such as I would say nine and it was about nine are likely.
It's similar to asking someone throwing dice what s/he has just thrown. The response could be either I threw a six or I threw six.
In this context, the latter answer cannot be misinterpreted as six throws rather than the number six. Both responses are perfectly clear and idiomatic.