Because we would use the word "him"....I voted for him, the correct word is whom, like the example you gave in the second sentence..."for whom did you vote?" That is correct.
However, in these days, that is a little too formal for conversation, and in America you would definitely hear "Who did you vote for"?