"Put a sock in it" is slang for "Shut up". If you tell someone, "Put a sock in it!", it usually means that that person has been rambling on about nothing, complaining, or talking about something you don't agree with.
The phrase "Put a sock in it" refers to actually stuffing a sock in your mouth. The idea is that if you put a sock in your mouth, you cannot speak, or your speech is muffled/stifled.