On Inherent Vice, the protagonist is called Larry, but everyone calls him 'Doc'?
Why do they do that?
At first I thought he was actually a doctor (a stoned one), but then I saw he was working as a Private Investigator.
The given nickname is explained in the book.
When Larry 'Doc' Sportello was out of college, he had many debts to pay; back then he was simply known as Larry. The agency came after him and decide to hire him as a skip-tracer trainee to work his debt off. One of the things he had to do was to intimidate people to pay money they owed and he was allowed to carry a weapon; not a gun, but a truth-serum of some kind.
When he was interrogating people, they saw it and were afraid. It never became the tool of his trade, but it got him the nick name 'Doc'.
"What - kind of 'weapon' is that?"
"It's a hypodermic outfit"
"I knew that, but what am I supposed to load it with?"
"Truth serum. Same kind the CIA uses. [...]
Larry decided to stash the outfit in a sinister-looking red faux crocodile shaving kit [...] many of the delinquents he and Fritz visited couldn't keep their eyes off of it. [...] It never quite became a tool of his trade, but did develop into a useful prop, in time earning him the nickname 'Doc'.
Doc is just a nickname, albeit a no longer very common one. Clark "Doc" Savage, John Henry "Doc" Holliday, etc. Bugs Bunny calls Elmer Fudd "Doc" to be a smart-alec. In The Shining Dick Hallorann calls Danny "Doc", as that's the nickname his parents use.
It seems like a lot of the usage was from the turn of the last century through the 40's, but I guess it was still common enough in the 70's to make it into The Shining and Inherent Vice