So recently I've been able to learn some decent sized chunks of music by ear, something I've never been able to do before.
Figuring out the melodies and rhythms by ear has actually been pretty painless, 5-10 minutes and I can get it down.

However, I read music, and I'd like to be able to put down the things I'm hearing on a staff. If this makes sense, I can hear the rhythm and play it on my instrument, but when it comes to writing that down, I'm unsure how or where to begin. I'm a bit afraid of making mistakes, so I give up any attempts pretty fast.

Any tips?
You should probably spend some time with a metronome if you want to get better at hearing rhythms properly. So set the metronome on a relaxed tempo, and practice some basic rhythms. If you play two notes per each click, you're playing eighth notes, if you play three, you're playing triplets, if you play with a swing feel you're probably playing combinations of dotted eighths and sixteenth notes etc. This will help you visualize where the notes fall on the staff, since if the song is in 4/4, each four clicks is a bar, and you can visualize when the bars change and how the rhythm relates to the beats.

And rhythm is more of a body thing than an ear thing. You feel rhythm through movement. Can you do the following: pick a riff you like, not too fast or hard, and tap your foot to the beat. Can you play the riff while tapping the beats simultaneously? This is a good way to develop your sense of rhythm. A harder variant, but a more rewarding one, is counting the beats out loud (one-two-three-four...) while you're playing, which is definitely not easy, but will do wonders to your ability to feel rhythm.

You probably need a little bit of knowledge on rhythm-related theory as well. You need to understand time signatures, beats, subdivisions, n-tuplets, dotted notes and all of that to be able to notate rhythm fluidly. You should start off with basic subdivisions like quarter notes, eight notes, half notes etc., then dotted notes and triplets. These are all you'll need for most popular music, at least for a start. 

What you're asking is a bit vague and would probably require an essay for an in-depth answer, but practicing with a metronome, doing the exercises I recommended and studying some theory will get you started.
Quote by Jet Penguin
Theory: Not rules, just tools.

Quote by Hail
*note that by fan i mean that guy who wants his friends to know he knows this totally obscure hip band that only he knows about with 236 views on youtube. lookin' at Kev here
I learnt about notating music from transcriptions in guitar mags and tab books, so if you have anything like that study it and listen to the song to learn how the notation relates to what you're hearing. You can also use the Guitar Pro tabs that are here on UG, but be aware that not everyone making GP tabs really knows how to properly write down music ...