Bhagavad Gita

ಕರ್ಮಣೈವ ಹಿ ಸಂಸಿದ್ಧಿಮಾಸ್ಥಿತಾ ಜನಕಾದಯಃ ।
ಲೋಕಸಂಗ್ರಹಮೇವಾಪಿ ಸಂಪಶ್ಯನ್ ಕರ್ತುಮರ್ಹಸಿ ॥೨೦॥
karmaṇaiva hi saṃsiddhimāsthitā janakādayaḥ |
lokasaṃgrahamevāpi saṃpaśyan kartumarhasi ||20||

Gist of the sloka:
Being in the karma yoga itself, King Janaka achieved his goal - educating the populace about the duty to perform one’s duty, do yours.
Ancient Raja rishis have walked in this path of karma yoga and have achieved mukthi. They never renounced their duty and entered the forest. The good example of such a Raja rishi is King Janaka. Lord Krishna says, that these rishis by performing karma yoga itself obtained right knowledge, and continuing to perform their duties, rose to the level of mukthi; not by renouncing the performance of their duties. Lord says, being a responsible model for the populace, perform your duties and show to the world how it needs to be done.
King Janaka, was a great king ruling over a prosperous kingdom. He had every kind of comforts and richness possible. He was also a great gynani of his times. When Shukhacharya, son of Lord Vyasa [Veda Vyasa rishi or Krishna Dwaipayana] approached his father to instruct him on detachment, Lord Vyasa asked him to meet King Janaka.
When Shukhacharya met him, the King asked him to be housed at a cottage and gave him all the comforts. He did not attempt to meet him. This went on for over a week. The King was observing him to see if he would be tempted with the comforts or would lose control and become angry. When that did not happen, King warmly welcomed the son of Lord Vyasa and instructed him accordingly. This was in a way, for the King to test, if the student was ready for such lessons.
In the second instance, King was in midst of a chess game when fire broke out in the city of Mithila his capital. The guards rushed to the king and told him: Your Mithila is burning down. The King calmly replied that they were wrong. The City of Mithila existed before him and would continue to do so after him. Mithila did not belong to him. That was the nature of his mind, which did not get disturbed at the news nor was he attached to any material objects. He as his duty as the king, did provide the subjects necessary materials, money and comfort to overcome the burning of their homes etc., He looked at himself as a custodian not as an owner.
This and many more, is the reason why Lord Krishna to invoke the King’s name in Gita.