In the first Chapter of the Gospel of Luke, we are told the story of the aged priest, Zechariah, and his wife, Elizabeth, and how they had no children, but that they devotedly prayed to God to bless them with one. They were not young, so the prospect of this happening seemed less and less likely as time passed. But, one day, while Zechariah was fulfilling his duties in God’s Temple, the Archangel Gabriel appeared with a message from God. Gabriel brought the message that God had heard their prayer. Elizabeth would bear Zechariah a son and his name would be John. Gabriel told Zechariah that his son would bring great joy and gladness at birth; He would be the one who prepared the way for the coming of Jesus Christ, the long-awaited Messiah. Zechariah’s and Elizabeth’s prayers were not only answered, the prophecy about their son exceeded their expectations.
Zechariah was probably dumbfounded by this wonderful news and great prophecy. So, what did he do when he heard it? He asked for proof. Zechariah asked the angel, “How can I be sure of this? I am an old man and my wife is well along in years.” (Luke 1:18) Said another way, Zechariah’s question could be literally translated as “According to what will I know this?” From this, the uncertainty in Zechariah’s question is obvious. Instead of praising God, Zechariah doubted; he did not believe.
As a result, God takes Zechariah's voice. The angel said to him, “I am Gabriel. I stand in the presence of God, and I have been sent to speak to you and to tell you this good news. And now you will be silent and not able to speak until the day this happens, because you did not believe my words, which will come true at their appointed time.” (Luke 1: 19-20)
It is evident from the text that Zechariah was punished because he "did not believe." In Bible commentary, Mathew Henry very simply notes, "His unbelief was silenced." Leaving the Temple, he could not brag about the vision, nor question the prophecy. In fact, he was not able to speak until after he wrote "his name is John," testifying of his belief and submitting himself to the truth, after his son was born.
This is similar to what happened to Paul on the road to Damascus. He could not "see" (metaphorically) the truth, so God blinded him until he saw the truth. (Acts 9:3-9) Also, with King Nebuchadnezzar - he went mad until he gave praise to God. (Daniel 4:28-37) And thus, with Zechariah, he would not testify of the truth, so he was silenced until he would testify of the truth - and when he did, his speech was restored to him.
So, therefore, we conclude that the punishment given to Zechariah was to stop the disbelief, and was lifted when the disbelief ended. This had the added benefit of testifying to the truth, because immediately after saying "his name is John," he was able to speak - that direct correlation speaks to the validity of the vision with Gabriel.