Both sentences are correct.
In English there are two kinds of phrasal verbs: separable and inseparable.
1.separable phrasal verbs are for example: shave off, switch on/off, get on/off.
Separable means you can use the particle on/off, ect. before or after the object.
In case you use an object pronoun like IT ,
you have to put the particle after the pronoun. So you have to say "Shave it off".
You can't say "shave off it".
2.Inseparable phrasal verbs are for example: look after, come across, count on.
"I look after my niece" not "I look my niece after".