The comment 'You are too young to be a professor.' doesn't sound like a compliment. The implication is that he/she isn't experienced enough for the role.
'You look too young to be a professor', if aimed at a woman, is probably meant to be a compliment.