Do not cast me from your presence
or take your Holy Spirit from me.
This verse used to confuse me. Why would David be asking God these questions?
In II Corinthians 1:21-22 it tells us --
Now it is God who makes both us and you stand firm in Christ. He anointed us, set his seal of ownership on us, and put his Spirit in our hearts as a deposit, guaranteeing what is to come.
The Holy Spirit is our seal. It is a mark of God's ownership on us, and it is the guarantee that there is more to come for us. We cannot remove the seal of God.
And we can see a similar concept in Ephesians 4:30 --
And do not grieve the Holy Spirit of God, with whom you were sealed for the day of redemption.
In this passage, it can even be seen that this seal is not removed even when we are grieving the Spirit.
The best way to understand Psalm 51:11 is to first realize that David had not received the full revelation of the Word of God. There were many mysteries that had not been revealed yet. They did not fully comprehend the truth of who the Christ would be. So David was speaking on what he understood.
But regardless of whether or not David understood these concepts, there are many examples in the Bible of people asking God for things that He had already promised.
When I am at the grocery store, when I am returning my cart to the cart return in the parking lot, sometimes I keep my son with me. And it never fails, right before I start to pick him up, he will say, "Daddy! Don't leave me!" He always does this with a smile on his face, because we both know that I would never leave him in the cart.
This is the same thing that I believe David is doing. He says, "Don't cast me from your presence, Don't take your Spirit from me!" Both God and David know that these things would never happen, but David cries out anyway.
It shows his dependence on God, and his desire for God to be there.