Hello Rozali,
They both could be used interchangeably in many cases to give permission in a polite way for example:
"Can I use your cellphone ?"
"Of course, you can."
or
"Sure, you can."
You can use both.
'Of course' means it is a normal thing ,it goes without saying .It emphasizes someone's agreement "of course" or disagreement " of course not".
'Sure' means it is definite, certain and free from doubt. It emphasizes that something (using the phone here) is reliable. It is also many times just an informal way of saying 'yes' or 'all right' .