In dialogue, spell it out. No one can speak a number. It’s impossible. That’s why we have words that represent numbers. In articles, this page sums it up pretty well. http://www.grammarbook.com/numbers/numbers.asp
Rule one is fuzzy because it depends on who you’re writing for. Just be consistent, and you’ll do fine.