From Spiritual living 360:
One such story says that Brahma created a woman named Shatarupa to help him with his job of creation. According to the myth, Shatarupa was so beautiful that Brahma became completely infatuated with her and stared at her wherever she went. Shatarupa was embarrassed by this attention and tried to escape his gaze, but in every direction that she moved, Brahma sprouted a new head until he had developed four. The frustrated Shatarupa became desperate and began to jump to try to escape his gaze. This prompted Brahma to sprout yet another head on top of the others in order to keep her in sight.
It is said that Shiva admonished Brahma for his "unholy" behavior towards Shatarupa and chopped off his fifth head as punishment. Brahma had given into the cravings of the flesh and abandoned the work of the soul and for this Shiva's curse was that people should not worship Brahma.
The story also goes on to say that Brahma has been continually reciting the four Vedas ever since as a form of repentance, one from each of his four heads.
I have seen the same story in other links too.
But I have also found a reference where there is no description of what I have referred from above links.
EDIT: (added after @Dineshkumar's comment below)
From Siva Purana, Jnanasamhita 49:65-80:
Brahma desired Sarasvati and went to her, asking her to stay with him. She, being his daughter, was furious at this and said, 'Your mouth speaks inauspiciously and so you will always speak in a contrary way.' From that day, Brahma's fifth head always spoke evilly and coarsely. Therefore one day when Siva was wandering about with Parvati and came to see Brahma, Brahma's four heads praised Siva but the fifth made an evil sound. Siva, displeased with the fifth head, cut it off. The skull remained stuck fast to Siva's hand, and though he was capable of burning it up, Siva wandered the earth with it for the sake of all people, until he came to Benares.