For me it's pretty much a matter of how often I use whatever it is in question. When it's just for an exam or a few homework problems and you don't use it often after that, I don't know why you would commit it to long term memory! But when you use something many times in other courses, it gets dug in pretty good, and as far as I know that's the only sure way to do it.
After all, if you don't use it that often, why does it need to be committed to memory? It's unrealistic to think you can instantly recall everything you've ever learned. What's important is that when you run into something you don't immediately know how to do, you know where to look to get a quick refresher so that you do remember and can solve the problem or whatever. A professor of mine gave me this advice, and I have found it invaluable.