Brahma, the creator of the universe, is depicted as having four heads. Is there a story behind it?
The story of how Brahma got four heads is told in this excerpt from the Matsya Purana. When Brahma created Saraswati, he immediately fell in love with her, and she evaded him by going in different directions, but he sprouted a head in each of the four directions until finally she went above him and he grew a fifth head pointed towards Devaloka:
Lord Brahma, after creating His manasa putras, was not quite satisfied with the work of His creation. He set about devising some plan which would carry on the work of creation and would relieve Him of the task. With this view, He began to invoke Gayatri. After some time the goddess Gayatri, known under different names, viz. — Satarupa, Savitri, Sarasvati, Brahmani, &c, — appeared in the form of a girl from the half portion of Brahma's body who at the first sight mistakenly took Her for His daughter. Afterwards, the Creator, seeing that form of exquisite beauty, was fired with love and repeatedly uttered, " What an enchanting form!" At this, the MAnasa putras of Brahma, i.e., Vasishtha, etc., taking Savitri for their sister, began to express their feelings of seething indignation and contempt at the attitude of Their Father (Lord Brahma), but He was so much absorbed in love that He did not heed anything in the least.
Brahma continued uttering, " Oh ! what an enchanting form ! oh ! what an enchanting form !" in His love for the goddess Savitri, and the latter, after saluting Him, began to circumambulate Him in reverence. Brahma fixed his gaze on Savitri and could not distract Himself from Her. As she was circumambulating Him, He felt shy of turning His head each time to Her direction, as His Mftnasa putras were standing close by. He therefore created four heads, each pointed to a direction, in order that He may see Savitri undisturbed, without having to turn His head each time in course of Her circumambulations. Seeing Brahma in such a condition, Satarupa went to heaven with the Manas sons of the Creator, and as she was travelling towards heaven, Brahma put on a fifth head right on top which afterwards He covered with His long matted hair. This is how Brahma came to have five heads. After this, Brahma lost his powers that He had acquired by practicing asceticism, owing to His not controlling His mind and falling into the snares of Cupid. Then Brahma dispersed His sons, after directing them to carry on the work of Creation.
The sons of Brahma, in obedience to His instructions, set themselves to complete the work of creation, and afterwards they took leave Of Brahma with salutations. Brahma, fired with passion in Her company, married Satarupa and began to pass His days in enjoyment inside a lotus. He enjoyed the company of Savitri for hundred years, and after a long time Manu was born to them.
Note that Saraswati, although she's often called by the name Shatarupa, is not the same as Shatarupa wife of Swayambhuva Manu.
In any case, this passage doesn't discuss how Brahma lost his fifth head. It was cut off by Shiva in his incarnation as Kala Bhairava; here is how the Shatapatha Brahmana of the Yajur Veda describes it:
Pragâpati conceived a passion for his own daughter... 'May I pair with her!' thus (thinking) he united with her. This, assuredly, was a sin in the eyes of the gods. 'He who acts thus towards his own daughter, our sister, [commits a sin],' they thought. The gods then said to this god who rules over the beasts (Rudra), 'This one, surely, commits a sin who acts thus towards his own daughter, our sister. Pierce him!' Rudra, taking aim, pierced him.
That's an extremely abbreviated telling, but the Jnana Samhita of the Shiva Purana provides more detail (Jnana Samhita 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.
So it's after losing the fifth head that Brahma got the well-known four-headed form he has today.