The Electoral College members for each state are voted on by the state's residents on voting day. In some states, the electors' names are printed on the ballots directly under the presidential candidates' names or grouped by party somewhere else on the ballot. In other states, the names of electoral college nominees are not even listed on the ballot.
When you vote for a presidential and vice-presidential candidate on the ballot, you are really voting for the electors of the political party (or unaffiliated candidate) by which they were nominated. Take the North Carolina General Statute § 163-209, for example: "A vote for the candidates for President and Vice-President named on the ballot is a vote for the electors..." [source: North Carolina General Assembly].
This is the case for 48 states. It's known as the winner-take-all system, where all electors go with the candidate who wins the popular vote regardless of how close the vote is. So if the Democratic candidate narrowly wins the popular vote in Texas, for instance, 38 Democratic electors (38 being the total number of electoral votes in the state) will represent Texas as a voting block.
The other system, known as the congressional district method, is observed in Maine and Nebraska. In these states, the vote is split between the electoral vote which goes to the winner of the statewide popular vote and the congressional district vote. The state is divided into congressional districts, each with one electoral vote. The winner of the popular vote in each district is awarded an electoral vote. Potentially, this could result in a divided electoral vote but so far it has not happened in either state [source: Cornell University Law School].
Most of the time, electors cast their votes for the candidate who has received the most votes in the state he or she represents, or for the candidate affiliated with his or her political party. However, there have been times when electors have voted contrary to the people's decision. When electors cast their vote without following the popular vote or their party vote, they are known as faithless electors [source: Weingast].
In response to faithless electors' actions, at least two dozen states have created laws to enforce an elector's pledge to his or her party vote or the popular vote. Some states even assess a misdemeanor charge and a fine. For example, the state of North Carolina fines faithless electors $10,000. However, a number of scholars believe such state-level laws would not survive constitutional challenge; of the 158 faithless electors, none have ever been punished [source: Project Vote Smart].