I will provide quotes from The Chicago Manual of Style, 17th ed., and from The Editors Blog. The links to Chicago are behind a paywall and, unfortunately, can only be viewed if you have a subscription.
While these generally hold true across most style guides (in both English in general and literature specifically), other style guides may give different guidance. And note that none of these guides provide absolute rules. The key is to pick a style (or identify which one is expected of you) and to use it consistently.
The guidance for dialogue is often different from the guidance for narrative.
In nontechnical contexts, Chicago advises spelling out whole numbers from zero through one hundred and certain round multiples of those numbers (see 9.4).
Thirty-two children from eleven families were packed into eight vintage Beetles.
Many people think that seventy is too young to retire.
The property is held on a ninety-nine-year lease.
According to a recent appraisal, my house is 103 years old.
The three new parking lots will provide space for 540 more cars.
The population of our village now stands at 5,893.
Many publications, including those in scientific or journalistic contexts, follow the simple rule of spelling out only single-digit numbers and using numerals for all others (but see 9.7). Most of the exceptions to the general rule (9.2) also apply to this alternative rule. Round multiples of hundreds, thousands, and hundred thousands, however, are typically expressed as numerals when the alternative rule is in force (cf. 9.4).
The whole numbers one through one hundred followed by hundred, thousand, or hundred thousand are usually spelled out (except in the sciences or with monetary amounts)—whether used exactly or as approximations.
Most provincial theaters were designed to accommodate large audiences—from about seven hundred spectators in a small city like Lorient to as many as two thousand in Lyon and Marseille.
A millennium is a period of one thousand years.
The population of our city is more than two hundred thousand.
Some forty-seven thousand persons attended the fair.
The official attendance at this year’s fair was 47,122.
In a context with many large numbers—especially if round numbers occur alongside numerals that are not round—it may be best to opt for numerals for all such numbers. See also 9.7.
Where many numbers occur within a paragraph or a series of paragraphs, maintain consistency in the immediate context. If according to a given rule you must use numerals for one of the numbers in a given category, use them for all in that category. (An exception should be made at the beginning of a sentence.) In the same sentence or paragraph, however, items in one category may be given as numerals and items in another spelled out. According to the general rule, in the first example, the numerals 50, 3, and 4 would normally be spelled out (see 9.2); in the second and third examples, 30,000 and 2,000, respectively, would normally be spelled out (see 9.4). According to the alternative rule, in the fourth and fifth examples, 9 and 1, respectively, would normally be spelled out (see 9.3).
A mixture of buildings—one of 103 stories, five of more than 50, and a dozen of only 3 or 4—has been suggested for the area.
In the second half of the nineteenth century, Chicago’s population exploded, from just under 30,000 in 1850 to nearly 1.7 million by 1900.
Between 1,950 and 2,000 people attended the concert.
Though most of the test subjects were between 13 and 18, two were 11 and one was 9.
The movie lasted 1 hour and 36 minutes, a typical length for a romantic comedy.
An exception to either rule may also be made to avoid a thickly clustered group of spelled-out numbers, regardless of category. And in some cases, an exception may be applied not only to a paragraph or passage of text but to a work as a whole. If, for example, a book includes many mentions of ages, all ages might be given as numerals. For numerals in direct discourse, see 13.44.
As can be seen, there are general suggestions, but, as in this last quoted Chicago section, strictly following one or the other rule isn't always a good thing; if doing so would cause confusion in reading and understanding something, then the so-called rules can be bent. Reader comprehension should always trump everything else.
In quoting directly from spoken sources (e.g., interviews, speeches, or dialogue from a film or a play), or when writing direct discourse for a drama or a work of fiction, numbers that might otherwise be rendered as numerals can often be spelled out. This practice requires editorial discretion. Years can usually be rendered as numerals, as can trade names that include numerals. And for dialogue that includes more than a few large numbers, it may be more practical to use numerals. See also 9.2, 9.7.
Jarred’s answer was a mix of rage and humiliation: “For the last time, I do not have seven hundred thirty-seven dollars and eleven cents! I don’t even have a quarter for the parking meter, for that matter.”
Like most proofreaders, she is a perfectionist. “I’m never happy with a mere ninety-nine and forty-four one-hundredths percent.”
“Do you prefer shopping at 7-Eleven or Circle K?”
“I didn’t get around to reading Nineteen Eighty-Four until 1985,” he finally admitted.
“My mobile number is 555-0133.”
"Numbers in Fiction" by Beth Hill at The Editor's Blog echoes Chicago, and even recommends it, in addition to pointing to the Associated Press Stylebook for newspaper and magazine writing. It also gives a lot of detail on numbers that I will not provide all here.
But I will quote its section on using numbers in dialogue (which, it too, says is different from the use of numbers in narrative):
__ Spell out numbers in dialogue. When a character speaks, the reader should hear what he says. And although a traditional rule tells us not to use and with whole numbers that are spelled out, keep your character in mind. Many people add the and in both words and thoughts. Once again, the rules are different for fiction.
“I collect candlesticks. At last count I had more than a hundred and forty.”
“At last count I had more than one forty.”
“She gave her all, 24/7.” Incorrect
“She gave her all, twenty-four seven.” Correct
One exception to this rule is four-digit years. You can spell out years, and you’d definitely want to if your character has an unusual pronunciation of them. But you could use numerals.
“He told me the property passed out of the family in 1942.”
“I thought it was fifty-two?”
A second exception would be for a confusing number or a long series of numbers. Again, if you want readers to hear the character saying the number, spell it out. Even common numbers might be spoken differently. One character might say eleven hundred dollars while another says one thousand one hundred dollars.
If you have to include a full telephone number—because something about the digits is vital—use numerals, even in dialogue. (But if you want to emphasize the way the numbers are spoken, spell out the numbers.)
You’d use numerals rather than words because writing seven or ten words for the numbers would be cumbersome. But most of the time there is no reason to write out a full phone number.
__ Write product and brand names and titles as they are spelled, even if they contain numbers—7-Eleven, Super 8 hotels, 7UP.
There are many more specific details and discussions in both of these resources, as well as in other style guides. A list of all guidance, especially as it differs from one source to another, would be too long to reasonably reproduce here.
But while Chicago is behind a paywall, "Numbers in Fiction" at The Editors Blog is not, and it can be read in full at its source. (Although, as I've mentioned, it's not a single authority.)