1 John 2:3-5 (NIV)
We know that we have come to know him if we obey his commands. The man who says, "I know him," but does not do what he commands is a liar, and the truth is not in him. But if anyone obeys his word, God's love is truly made complete in him. This is how we know we are in him.
Actually John is far more blunt than my title would suggest. He calls the person who claims to know him a liar if there is no evidence of it. Couldn't the evidence be something besides obedience, like wearing a cross around your neck or even going to church every Sunday? The implication here is that the one who knows Him does all of His commands, not just some of them.
The Bible is very clear that it is not by our keeping commands that we come to know him. That happens by trusting that He is able and willing to save anyone who comes to Him and then placing your faith in that promise.
If we can't know him by keeping his commands, the opposite is true. That is, coming to know Him will produce obedience to His commands. There is no hint that the motivation for obedience here is gratitude for what Christ has done, rather it seems a necessary result of knowing Him. I see that happening in my own life. The more I know Him the more I want to obey Him. It seems that He is the one producing the desire and motivation to be obedient. I love His words and His promises for my future--here on this earth and ultimately in Heaven.
John Piper's book Future Grace was a great help to me in understanding this.