Gold Flowers that are obtained within stages always expire at the end of that stage. The exception to that rule is Gold Flowers retrieved from Star Toad Houses, which are automatically deposited into your lower screen's inventory when you visit that Toad House. Star Toad Houses are the yellow Toad Houses that you see on the overworld map, contrasting the green and red Toad houses.
If you are playing Coin Rush mode, you always get one Gold Flower in your inventory to use at your own discretion. It expires at the end of the level you activate it on, if you don't lose it before then.