The demon named Vṛka, a son of Śakuni’s, once met Nārada on the road. The wicked fellow asked him which of the three chief gods could be pleased most quickly. Nārada told him, "Worship Lord Śiva and you will soon achieve success. He quickly becomes pleased by seeing his worshiper’s slightest good qualities — and quickly angered by seeing his slightest fault. He became pleased with ten-headed Rāvaṇa, and also with Bāṇa, when they each chanted his glories, like bards in a royal court. Lord Śiva then bestowed unprecedented power upon each of them, but in both cases he was consequently beset with great difficulty."
Thus advised, the demon proceeded to worship Lord Śiva at Kedāranātha by taking pieces of flesh from his own body and offering them as oblations into the sacred fire, which is Lord Śiva’s mouth. Vṛkāsura became frustrated after failing to obtain a vision of the lord. Finally, on the seventh day, after dipping his hair into the holy waters at Kedāranātha and leaving it wet, he took up a hatchet and prepared to cut off his head. But at that very moment the supremely merciful Lord Śiva rose up out of the sacrificial fire, looking like the god of fire himself, and grabbed both arms of the demon to stop him from killing himself, just as we would do. By Lord Śiva’s touch, Vṛkāsura once again became whole.
Lord Śiva said to him: "My friend, please stop, stop! Ask from me whatever you want, and I will bestow that boon upon you. Alas, you have subjected your body to great torment for no reason, since I am pleased with a simple offering of water from those who approach me for shelter." The benediction sinful Vṛka chose from the lord would terrify all living beings. Vṛka said, “May death come to whomever I touch upon the head with my hand.”
Upon hearing this, Lord Rudra seemed somewhat disturbed. Nonetheless, O descendant of Bharata, he vibrated om to signify his assent, granting Vṛka the benediction with an ironic smile, as if giving milk to a poisonous snake. To test Lord Śambhu’s benediction, the demon then tried to put his hand on the Lord’s head. Thus Śiva was frightened because of what he himself had done. As the demon pursued him, Lord Śiva fled swiftly from his abode in the north, shaking with terror. He ran as far as the limits of the earth, the sky and the corners of the universe. The great gods could only remain silent, not knowing how to counteract the benediction. Then Lord Śiva reached the luminous realm of Vaikuṇṭha, beyond all darkness, where the Supreme Lord Nārāyaṇa is manifest. That realm is the destination of renunciants who have attained peace and given up all violence against other creatures. Going there, one never returns.
The Supreme Lord, who relieves His devotees’ distress, had seen from afar that Lord Śiva was in danger. Thus by His mystic Yoga-māyā potency He assumed the form of a brahmacārī student, with the appropriate belt, deerskin, rod and prayer beads, and came before Vṛkāsura. The Lord’s effulgence glowed brilliantly like fire. Holding kuśa grass in His hand, He humbly greeted the demon. The Supreme Lord said: "My dear son of Śakuni, you appear tired. Why have you come such a great distance? Please rest for a minute. After all, it is one’s body that fulfills all one’s desires. O mighty one, please tell Us what you intend to do, if We are qualified to hear it. Usually one accomplishes his purposes by taking help from others." ... Thus questioned by the Personality of Godhead in language that poured down upon him like sweet nectar, Vṛka felt relieved of his fatigue. He described to the Lord everything he had done.
The Supreme Lord said: "If this is the case, We cannot believe what Śiva says. Śiva is the same lord of the Pretas and Piśācas whom Dakṣa cursed to become like a carnivorous hobgoblin. O best of the demons, if you have any faith in him because he is the spiritual master of the universe, then without delay put your hand on your head and see what happens. If the words of Lord Śambhu prove untrue in any way, O best of the demons, then kill the liar so he may never lie again.".
Thus bewildered by the Personality of Godhead’s enchanting, artful words, foolish Vṛka, without realizing what he was doing, placed his hand on his head. Instantly his head shattered as if struck by a lightning bolt, and the demon fell down dead. From the sky were heard cries of “Victory!” “Obeisances!” and “Well done!”. The celestial sages, Pitās and Gandharvas rained down flowers to celebrate the killing of sinful Vṛkāsura. Now Lord Śiva was out of danger.
The Supreme Personality of Godhead then addressed Lord Giriśa, who was now out of danger: “Just see, O Mahādeva, My lord, how this wicked man has been killed by his own sinful reactions. Indeed, what living being can hope for good fortune if he offends exalted saints, what to speak of offending the lord and spiritual master of the universe?”. Lord Hari is the directly manifest Absolute Truth, the Supreme Soul and unlimited ocean of inconceivable energies. Anyone who recites or hears this pastime of His saving Lord Śiva will be freed from all enemies and the repetition of birth and death.
I don't think the specific story of Vishnu turning into Mohini to deceive this demon (as portrayed e.g. in the Sohal Nati dance) is in any of the Puranas. Devdutt Pattanaik claims in this book that it's in the Vishnu Purana, but you can search in the Vishnu Purana yourself; it doesn't seem to be there. Apparently it is there, though, in the Buddhist text Satara Dewala Devi Puvata according to page 146 of this book.