When you're using an auxiliary verb (such as "need", "want", "can", "will", "do", essentially a verb that adds meaning to another verb), you put the verb after it in the "infinitive" form, which 90% of the time, ends in "a" instead of "ar/er".
It's a similar reason as to why we leave out the 's' in "He needs to ask" (instead of "He needs to asks"), or "Does she have to do that" (Instead of "Does she has to does that")
It's grammatically correct, same construction as e.g. "You need only ask", which is accepted - only it contains a particle "to" as well which makes the sentence rendering a bit weird.
I'm honestly not sure whether I think it should be accepted. To me, it sounds a bit too 18th century, but if it's still in active use in regions of the native English-speaking world, then it should not be marked incorrect here.
It actually works the same in English - you do need the infinitive because it's preceded by a modal. But in English, the present and the infinitive are usually the same, so we have to switch to third person singular to see it:
- He only needs to ask <- infinitive, correct
- He only needs to asks <- present tense, incorrect