You can, if your dog ate a sock, induce vomiting at home but there are risks.
If the sock is particularly large, or the dog particularly small, it may become lodged in the throat on it's way out.
This is of course a choking hazard, a much better situation to be in when you're in a vet's office.