I believe that you referring to the Gossip Stones, correct? Well, they serve no big purpose really, but in both games they do tell the time when you strike them with the sword. In MM, it tells you how much time you have until the moon falls. They also can release fairies for you to capture if you play the Song of Storms or Zelda's Lullaby near them. The stones in MM don't do this. I may be wrong, but I don't think they do. Also when you're wearing the Mask of Truth in both games, and talk to the stones, they'll tell you interesting things about the people in the game and might even help you with some parts in the games.
In addition to what is stated above, in Majora's Mask there is one heart piece which is attainable by turning the 4 big Gossip Stones to the same color (http://www.zeldadungeon.net/Zelda06HeartPieces.php#20). I think there purpose is just to add another layer of depth to the game. In Ocarina of Time they also do funny/interesting things when hit with a fire arrow, megaton hammer, or a bomb...but I will leave that for you to find
Gossip stones have an important aspect on the story that is unlocked through the Happy Mask Shop side quest.
After obtaining the Mask of Truth from the end of the side quest, you can use them to interact with the Gossip Stones, and they will talk to you and give you information about secrets, characters, and society in Hyrule. The information they add is a great incentive to explore, and it provides a neat little way of putting together the pieces of the puzzle to figuring out the story in the game. The Mask of Truth side quest can be finished right after you beat the third dungeon. The hints that the game gives you can often bridge the gap between past and present, and allude to some interesting tidbits about the story and the world you inhabit.
Upon reflection, this seems like it is more suited to Zelda Game Help.
The gossip stones don't really do a lot to overall game play. But if you're really interested in the game, you just go around with the mask of truth and talk to them. Sometimes the information is worthless, and other times its funny and quite interesting. So, you don't need to worry about them if you don't want to.
If i am correct , those are Gossip stones . They are scattered around Hyrule and Termina . They tell you certain tips , advice , or sometimes some random Trivia . At first , in Ocarina of Time , the Gossip Stones would only tell you the time . In order for it to tell you advice , you need to complete the Mask Trading in Ocarina of Time, once you do , the Happy Mask Salesman will give the Mask of Truth , which will allow the player to communicate with the Gossip Stones .
In majora's Mask , if you would play the Song of Storms right in front of a Gossip Stone , you would wash out a Fairy. And if you happen to Place a bomb in a Gossip Stone , the Gossip Stone will surely act like a rocket and fly towards Skyward .