Mahabharata Mausala Parva, Chapter 4 (Mahabharata 16.4)
Proceeding then to the forest, Keshava beheld Rama sitting in a solitary spot thereof. He also saw that Rama had set himself to Yoga and that from out his mouth was issuing a mighty snake. The colour of that snake was white. Leaving the human body (in which he had dwelt so long), that high-souled naga of a 1,000 heads and having a form as large as that of a mountain, endued besides with red eyes, proceeded along that way which led to the ocean. Ocean himself, and many celestial snakes, and many sacred Rivers were there, for receiving him with honour. There were Karkotaka and Vasuki and Takshaka and Prithusravas and Varuna and Kunjara, and Misri and Sankha and Kumuda and Pundarika, and the high-souled Dhritarashtra, and Hrada and Kratha and Sitikantha of fierce energy, and Chakramanda and Atishanda, and that foremost of Nagas called Durmukha, and Amvarisha, and king Varuna himself, O monarch. Advancing forward and offering him the Arghya and water to wash his feet, and with diverse other rites, they all worshipped the mighty Naga and saluted him by making the usual enquiries.
However, on the other hand, Krishna was also an avatar of Vishnu. But he went back to his own celestial place after his bodily death.
"'A fierce hunter of the name of Jara then came there, desirous of deer. The hunter, mistaking Keshava, who was stretched on the earth in high Yoga, for a deer, pierced him at the heel with a shaft and quickly came to that spot for capturing his prey. Coming up, Jara beheld a man dressed in yellow robes, rapt in Yoga and endued with many arms. Regarding himself an offender, and filled with fear, he touched the feet of Keshava. The high-souled one comforted him and then ascended upwards, filling the entire welkin with splendour. When he reached Heaven, Vasava and the twin Ashvinis and Rudra and the Adityas and the Vasus and the Viswedevas, and Munis and Siddhas and many foremost ones among the Gandharvas, with the Apsaras, advanced to receive him. Then, O king, the illustrious Narayana of fierce energy, the Creator and Destroyer of all, that preceptor of Yoga, filling Heaven with his splendour, reached his own inconceivable region.
What I knew was that Valarama is also an avatar of Vishnu. However, then who is this mysterious Naga? Why he went to the ocean? Do any other scriptures talk about this Naga? Why Valarama did not go back to heaven and become one with Vishnu?