In the school, especially in the examination, we have to use the kanji we've learned. In the formal document or something, too, we need to use kanji.
However, I think, in our daily life, there isn't specific rule. We can choose whatever we like if writing in hiragana / katakana doesn't confuse the meaning. For example, I prefer writing 友だち because I like this way and it seems to be soft TO ME. It depends on the person.
I hope other people give you their opinion.