It's a nickname, assigned because he's knowledgeable. Ace used nicknames often. She called Mel "Doughnut" and, of course, strongly preferred to be known by her own nickname -- "Everyone calls me Ace" -- because she detested her given name.
Ace generally used "Professor" in informal situations and "Doctor" in more formal ones, when a real name would be appropriate, such as when introducing him to someone: "I'm Ace and this is the Doctor." She also tended to use "Doctor" when she needed to convey to him that the situation was serious.
The use of nicknames seems to have been a feature of her background. When the Doctor took her back to Perivale a couple of years after she'd left, one of her near-contemporaries was known as "Midge" and his younger sister was called "Squeak".
Out of universeEdit
However, the genuine reason for all this stuff is a behind-the-scenes one, really. Ian Briggs, who wrote Ace's first story, "Dragonfire", deliberately kept Ace from being formally introduced to the Doctor until the last line of the story. That way, she could come up with a nickname on her own, and then he could correct her only at the final moment before the end credits.
So what happens in "Dragonfire" is this very odd situation of a girl the Doctor's just met oddly suddenly calling him "Professor" at 07:44 into episode 1. Thereafter, it's "Professor this" and "Professor that", with the Doctor never correcting her. I think Briggs meant for the audience to wonder why the Doctor never reacted to this odd name, so that the penultimate line of the story — "I'm not a professor, I'm the Doctor!" would have some dramatic effect. Whether that makes any logical sense — since the Doctor is frequently characterised as insisting people call him "Doctor" immediately upon introduction — is another matter. Whether McCoy succeeds in actually delivering the line with satisfactory force is even more of a puzzler. But it is quite clear that the "Professor" thing was a gag within the script of "Dragonfire", designed to allow the story to more or less end on the phrase, "I'm the Doctor".
The fact that she doesn't subsequently adhere to her promise to call him "Doctor" is, to me, the bigger question. I don't know why he lets her get away with it, because it's hard to imagine any other Doctor letting a companion get away with using another nickname like that. Certainly, there are many instances of the Doctor not allowing even the contraction of "Doctor" to "Doc" — much less the substitution of a whole different word.