From the Super Mario Wiki
Super Mario series
Super Mario Galaxy
Spiky Topman appear as regular enemies in the Battlerock Galaxy and the Dreadnought Galaxy. Spiky Topmen can use a spin attack which does not damage Mario, but push him backwards. However, the spin can push Mario into other hazards that may hurt him. In addition if Mario attempts to stomp a Spiky Topman or lands on one he will be hurt by the spike on its head. Mario can defeat the Spiky Topmen by using their own strategy against them, Mario's spin attack or a Star Bit can knock the enemies into electric fences causing them to explode. Each one defeated would give a Coin. Sometimes, when Spiky Topmen are defeated, they make a gate or door open leading to the next part of the level.
Super Mario Galaxy 2
They reappear again in Super Mario Galaxy 2, but only in the Space Storm Galaxy. They play a rather important role to getting the secret Power Star. After talking to the Silver Gearmo, he tells Mario to bring him a Spiky Topman in exchange for a Power Star.
Mario Kart Wii
Spiky Topmen made a return appearance in Mario Kart Wii as part of an online tournament that took place between June 1st to June 9th, 2008. The tournament took place on a special arena known as Galaxy Colosseum, and involved knocking four Spiky Topmen off the edge using Triple Mushrooms.