What action did John the Baptist to become a saint?

St. John the Baptist was ultimately beheaded by Herod because he refused to adore false images, and was directly related to Jesus Christ who at the time was complicating Herod's political aspirations with Rome.

The martyrdom of John the Baptist had nothing to do with him refusing to worship false images.

St. John the Baptist was a cousin of Our Lord and about 6 months older than him. He was a prophet charged with the task of preparing the "way of the Lord" and he did so by preaching and baptizing in the regions around Jerusalem. He had a large following, including some men who later became apostles of Our Lord. He eventually caught the attention of King Herod who became a "bit" upset as John demanded that he repent and change his immoral behavior. Herod had John thrown into prison and, at the urging of Herodias (his latest wife) and her daughter (Salome) had him beheaded. Read more about how John was martyred at the link below.