Hiragana and Katakana represent the same syllabary, but they are used for different purposes. Generally speaking, hiragana is used for Japanese native words, and katakana is used for words not of Japanese origin. In regard to writing words you have only heard pronounced, you have to memorize which characters are used for that word in order to spell it properly. A tip is that most adjectives and verbs are spelled in hiragana since the Japanese have their own words for these, and all particles use hiragana characters. Typically it is nouns that originated from a language other than Japanese that are spelled in katakana. An example of katakana use would be the word “basurumu”, which is the Japanese word for bathroom. This word is spelled with katakana as バスルーム. The word coffee, which is “kohi” in romaji, also uses katakana, and is spelled as コーヒー. It is important to note though, that most words in Japanese have a kanji character that is used instead of solely using hiragana. For example, the word tsunami, which in hiragana would be つなみ, is actually written as 津波 by using kanji. In order to be literate in Japanese you will need to learn all three scripts and their proper usage. Also, you should know that hiragana and kanji are often used together, even in the same word. It is difficult at first but just keep studying and it will make sense to you eventually. There are plenty of resources on the internet for this.
Any more questions? I will do my best to make this clear since I realize internet lessons can be confusing at times.
Keep in mind I do not speak Japanese as a native language and my fluency is minimal. However I have been studying it for some time.
Edit: My co-worker is studying Japanese and saw this as I was surfing Fluther and wanted to answer it lol.