Where did the phrase “put a sock in it” come from?
In terms of location, it comes from Britain. From ThePhraseFinder...
The imagery behind the phrase is that putting a sock in whatever was causing the noise would quieten it down. What that thing was isn't known. There are suggestions that this may have been the horn of an early gramophone or, more straightforwardly, the raucous person's mouth. [italics mine]
The author of that page says the earliest instance he could find was in the weekly literary review The Athenaeum, 1919. He points out that the fact that it was defined in the reference suggests the term was relatively new at that time. I found a reference a couple of years earlier in Happy - though Wounded! The book of the 3rd London General Hospital, 1917,...
"Put a sock in it, Fusiliers."
Hereupon a sudden and awful silence. The Night Sister has entered the ward.
I suppose the timing (and that earlier instance) makes it likely the expression arose in the military, as much slang does. So perhaps the thing that needed stuffing with a sock was the bugler's trumpet. (Or the piper's bagpipes - especially if he was practising, when others were trying to sleep!)