ANSWER: The phrase you are referring to that seems to discuss being baptized for the dead is found in only one verse in the entire King James Version Bible. It is located in the book of 1Corinthians, chapter 15, and verse 29. The verse in question is the following.
Else what shall they do which are baptized for the dead, if the dead rise not at all? why are they then baptized for the dead? (1Corinthians 15:29, KJV).
The Mormons (The Church of Jesus Christ of Latter-day Saints) use the above verse to justify their teaching that a person who is alive can be baptized for or on behalf of someone who is dead. After they perform this ritual, the spirit of the deceased person (according to the Mormons) can then either accept or reject the offered ordinance. This group has practiced this ceremony since 1840 A.D.
The belief that the efforts of those still alive, such as being baptized, can aid the dearly departed is not limited to the Mormons. The Catholic Church also teaches that humans can positively impact the eternal standing of those who have died. In their comments on 1Corinthings 15:29 they state, ". . . the passage at least furnishes historical evidence of the prevalence at the time of belief in the efficacy of works for the dead . . . it is probable that the practice in question was something in itself legitimate, and to which the Apostle gives his tacit approbation." (1913 Catholic Encyclopedia).
The general context of the chapter concerns those in Corinth who heard about Jesus being raised from the grave but still doubted, if not outright denied, that Christians (and ultimately everyone else) will someday experience the same thing (1Corinthians 15:12). Since the Bible nowhere teaches that we have an immortal soul, all humans must be resurrected first before receiving eternal life. Now, let us take a look at a more accurate translation of this verse.
29. Otherwise, what shall they do who have been baptized for the resurrection of the dead, if the dead are not raised at all? Why then are they baptized for the resurrection of the dead? (1Corinthians 15:29, HBFV)
Paul spends a good deal of time in chapter 15 linking Jesus' resurrection from the dead to our own. In fact, he makes the case that the doctrinal foundation of Christianity itself is based on the belief in his resurrection. If he was not brought back to life then we will not be as well. If this is true, then the Christian faith is a lie and a complete waste of time (1Corinthians 15:13 - 19). Christ, however, was raised from the dead and his life makes possible our life after we have perished (verses 20 - 28).
Paul's statement in 1Corinthians 15:29 merely rephrases his argument made a few verses prior. He states, in so many words, that being baptized and receiving God's spirit is made possible because of Christ's resurrection. Additionally, His life GUARANTEES that we will also live again. It therefore makes no sense for a true Christian to deny Jesus' resurrection, which is linked to our own, since that event makes our conversion possible.
In closing, it should be stated that 1Corinthians 15:29 cannot mean that someone who is alive can be baptized FOR, or otherwise affect, someone who had died. Baptism requires a person repent of their sins and accept Jesus as Savior, something that has to be done on an individual basis and cannot be done FOR someone else. Trying to "help" the deceased is also a waste of time since they are not conscious but are unconscious awaiting their return to life.