Question: when are hiragana and katakana used?
Answer: Hiragana is generally used for Japanese words when they're not written in kanji, and for all the grammatical "glue" such as conjugations and particles. Katakana is usually used for loanwords and onomatopoeia. There's no strict rule though, so you will see katakana used for other purposes as well, such as emphasis.