There is a concept in the laws of Torah reading known as "Keri" and "Ketiv," which refers to situations of a word spelled differently from the way it is to be pronounced. We have received through the Mesoret, the tradition transmitted from one generation to the next since the giving of the Torah at Mount Sinai, the details of how precisely the Torah is to be written, and how it is to be read. The term "Keri" refers to the way the words of the Torah are pronounced, while "Ketiv" refers to the proper spelling of words in the Torah scroll. Our oral tradition has taught that in some occasions the word is to be read differently from the way it is spelled.
The Shulchan Aruch, in a particularly fascinating passage (141:8), records an incident where a person read a word according to the "Ketiv," the way it is written, which differed from the "Keri" – the proper way for it to be read. Some of the generation's leading Rabbis were present at the synagogue and instructed the reader to read the word according to the "Keri," as Halacha requires, but he refused. The Rabbis consigned him to excommunication and forced him to step down from the Torah scroll. This incident demonstrates the importance afforded by the Rabbis to reading the Torah in accordance with our tradition.
The Mishna Berura (commentary to the Shulchan Aruch by Rabbi Yisrael Kagan, the "Chafetz Chayim," Lithuania, 1839-1933) notes that although the reader must not read any words of the Torah from memory, and must rather read it from the Torah scroll, he nevertheless reads the words according to the "Keri" even if it differs from the "Ketiv." Since this is how tradition teaches that we read the word, even though it is spelled differently in the written text, one may and must read in accordance with the "Keri." This applies even to the rare instances where an entirely different word is read in place of the word that appears in the written text (Devarim 28:27,30).
Nevertheless, Chacham David Yosef, in his work "Halacha Berura," writes that the reader should look at the written word as he reads, even in cases of a "Keri" and "Ketiv" where the pronunciation does not correspond to the spelling. Even though one does not read the word as it is written, he should nevertheless look at the written word in the Torah scroll as he reads the "Keri." He draws proof to this ruling from the reading of God's Name, which is written "H-V-Y-H" yet pronounced "Ado-nai." Halacha requires the reader to look at the written Name as He recites "Ado-nai," even though he does not pronounce the word as it is written. Similarly, in all cases where there is a discrepancy between the pronunciation and spelling, the reader must look at the word as he reads it, even though he does not read according to the spelling.
Summary: The one who reads the Torah must follow the traditional pronunciation of all words of the Torah, including those words that are not pronounced according to their spelling in the written text. Nevertheless, even in such cases the reader should look at the word as he reads it, despite the fact that he does not pronounce it as it is spelled.