Commas can be confusing, especially when it comes to their locations in an address.
Have you ever tried to write out someone's address and had no idea where to place the commas, so you ended up either randomly adding them in or forgoing them entirely? For those of you who still use snail mail, the commas are pretty self-explanatory since you really only need them between the city and state (the separate lines serve as comma breaks themselves):
First Line - House Number & Street Name
Second Line - City, State, & Zip Code
Third Line - Optional Zip Code (if you do not put it on the second line)
123 Main Street
Anytown, Michigan 12345
However, when you are writing out your address - say, in a message to a friend - then the commas become pretty important. Here's the rule: Commas should follow the house number/street name grouping, and separate the city/state.
That's it. It's exactly the same as writing it on an envelope except that you add a comma after the street name since there isn't a line break between that and the city/state. There should also never be a comma before a zip code (this is the same whether you are writing it on an envelope or within a sentence).
Let's take the address from above and translate it to how it would look within a sentence:
123 Main Street, Anytown, Michigan 12345.
See how it's exactly the same as above, except that the first comma has been added to designate between the house/street and the city/state? Make sense?
Et, voila. You'll be the address champ in no time.