We repented before we were baptized, but building faith in Christ and repenting are cycles we go through over and over again as we cycle upwards towards exaltation. As we do these things we are rewarded with the Gift and Spirit of the Holy Ghost.
We can receive the Spirit of the Holy Ghost as a testimony of truth before we're baptized, but that gift is temporary. Only after our baptism can we be blessed with the Gift of the Holy Ghost. That doesn't mean He will always remain with us, especially if we wander from the path and let go of the iron rod. He will warn us of the danger and prompt us to return, but the scriptures say that the Spirit will not always strive with man. We must constantly repent if we want to retain the power and influence and sweet presence of the Holy Ghost.
Boyd K. Packer said this about the Gift of the Holy Ghost:
“Put your trust in that Spirit which leadeth to do good—yea, to do justly, to walk humbly, to judge righteously; and this is my Spirit.
“… I will impart unto you of my Spirit, which shall enlighten your mind, which shall fill your soul with joy;
“And then shall ye know, or by this shall you know, all things whatsoever you desire of me, which are pertaining unto things of righteousness, in faith believing in me that you shall receive” (D&C 11:12–14).
“You will know after you decide! It takes an exercise of faith. You may not know at first and have that firm conviction, but it will come.”
But He doesn't force us to take it, nor does He force us to receive any of the gifts He gives us. He will never take away our agency. We must choose to receive His gifts. Brother Hart said that we are cups, and we can choose to be cups up or cups down. To receive means to take into one's possession something offered or delivered. "The directive in 2 Nephi 32:5 is that we must receive the Holy Ghost. This means not just receive the gift of the Holy Ghost but to receive the companionship of the Holy Ghost through righteous living and frequent involvement in activities which give the opportunity for the Holy Ghost to whisper in his still, small voice. If we do this, we have the promise that He will show us all things that we should do." http://www.gospeldoctrine.com/bomindex.html
I explained it to Acell this way: The UPS driver may have a package for me, so he brings it to the doorstep and sets it on the porch, rings the doorbell, and leaves. But if I don't answer the door and bring the package in and open it, the package does me no good. I can sit inside the house all day and wish I had the contents, or try to do without it. To receive any benefit from it, I must open the door and accept the package.
Of course, my analogy breaks down because the Lord doesn't drop off His gifts and leave. He's more like the driver who requires a signature (a covenant), so He waits at the door until I come and accept the gift. Here are some scriptures about receiving, in case you're not convinced: D&C 50::19-20; D&C 39:5; D&C 42:5; D&C 50:24; D&C 71:5-6; Jacob 3:2; 1 Cor 2:14; JST Matt 13:10-11.
The gifts from our Father are there for us if we seek them, but we must receive them with gladness and put them to use and treat them with respect. If Father's gifts are taken for granted or ignored or set aside or misused, He will cease to give us His gifts. That especially includes the gift of the Holy Ghost. We must respond and listen to the Holy Ghost, acting on promptings, in order to qualify to receive more. I know this is true and I'm striving every day to learn to be more sensitive to the Spirit and to act when prompted.