I would like to suggest something I was told while I was working on my tiesI was working on my ties. What you could do is to use some clear nail polish, not a lot, to stiffen the ends of the ribbon. That should prevent them from fraying at all. It is likely that you could use something like a super glue to accomplish the same thing.
You don't need a lot so, while it will darken the ribbon, if used sparingly it should not be noticeable.
Image from Wikihow
The page that comes from also suggests gluing as well as an alternative. It also covers using heat which Stephanie's answer covers betterStephanie's answer covers better.
Of course, that could also be seen as less then aesthetically pleasing. So to compliment my solution I would then suggest you use some thread and something simple like a tight overcast stitch. The thread will hold around the polish and hopefully distract from its presence. The nail polish alone should be enough to stop it from coming undone for a while. That would all depend on wear and tear at that point.