Of course it's grammatical.
Plus, it's more natural than put the socks on.
Now, an elliptically reduced version doesn't guarantee that the exact original version should also work. For example, I always have is an ellipted version of I always have loved you in the following example, but the latter doesn't work:
I love you, and I always have.
??I love you, and I always have loved you.
I love you, and I have always loved you.
The original version that's correct is the last one, which is not the exact original version of the elliped version.
If you replace the socks with them in your example, the only ellipted version that's correct corresponds to the exact original version:
Put them on.
Put them on your feet.
??Put on them.
The last version that's now incorrect corresponds to the most natural ellipted version of your example: Put on the socks.