I believe you are referring to The Song of Evil in The Pearl by Steinbeck.
Kino hears songs in his head that are his moral compass and warn him about events to come. The Song of the Family is a good song; it reflects Kino's happy life with his family. However, the Song of Evil is a warning song about the possibility of the destruction of the family:"In his mind a new song had come, the Song of Evil, the music of the enemy, of any foe of the family, a savage, secret, dangerous melody, and underneath, the Song of the Family cried plaintively (Chapter 1, paragraph 14). Unfortunately, the Song of Evil portends the destruction of his family.
The townspeople turn against Kino as greed takes over, and everyone wants the valuable pearl. Kino hears the Song of Evil, and it becomes a metaphor, a comparison, to the scorpion that stings Coyotito. The Song of Evil is the symbol of the family's destruction and the pain that follows the bite of the scorpion.