"Diselo al profesor". is the right way.. formed by many parts. Pay attention please:
-Di- from the verb "decir" is a contraction, the first person of the imperative, and it always goes together with a pronoun.
Then we have -SE- which is an INDIRECT OBJECT PRONOUN from (him/her/they) and -LO- which is also a pronoun but a DIRECT OBJECT PRONOUN (me, te , lo, la , los , las, nos, os, les) and in this construction represents "something of male gender", pay attention, not a male, but something ( a thing, an idea, a fact in abstract).
Thus, we have DI (from verb decir, first person imperative) SE (to him, personal pronoun, indirect object) LO ( the thought you have, the question you have in mind).
Of course, you can express the same situation using plane words, without the pronouns:
"Di(le) al profesor lo que piensas", but a Spaniard would use the pronominal form: Diselo al profesor...
As you would notice, in the phrase we have a contraction from the preposition "a" and the article "el": a el = al.
You only need to memorize two contractions in Spanish: al and del (both masculine. No contractions with the feminine forms).
"Dice el profesor" means simply ¨The teacher says