I know that you write in katakana when you are using foreign words and hiragana when dealing with Japanese words but I've seen some words that are mixed with both katakana and hiragana, so my question is how do you know which type of letters to use and in which part of the word??

Please help me on this. I really want to be good at writing in Japanese Thank you

That almost never happens except of for a few character's names or for emphasis (katakana can act like our bold or capital letters). ドラえもん is one example where the character's name is written with katakana and hiragana.