When they are part of the name, use the short form, though Professor and military ranks are normally written in full in dialogue. In British Englishwe normally write the short forms without a full stop (period.)
If the words are used on their own, then we use the full form:
"So, Doctor, is it serious?" asked Mary.
"Spare a copper, mister?" whined the street urchin.
Note that there are no expanded forms of Mrs or Ms.