In both games, his power grants Mario or Luigi the power to Star Spin. He briefly appears above their heads a couple seconds after they perform a Star Spin. This indicates that they can now do another. He also pops out of their hat to perform a little dance whenever they return to the Comet Observatory or the Starship Mario with a Power Star.
Super Mario Galaxy
In Super Mario Galaxy, Luma appears in the form of a Star Bunny. After catching Luma and his two companions, he will reveal Rosalina to Mario. Rosalina then bestows Luma upon Mario, granting Mario the Star Spin ability.
Throughout the entirety of Super Mario Galaxy, Luma assists Mario in his fight against Bowser. Luma stays in Mario's hat the entirety of the game, only popping his head out after the spin ability was performed.
In the ending, all of the Lumas, including Luma traveling with Mario or Luigi, fly towards the black hole, and turn into new galaxies. In the secret ending obtained by collecting 120 Power Stars, he is seen in the Gateway Galaxy near what is presumed to be the spaceship that Rosalina rode with her original apricot colored Luma.