This can definitely be a confusing issue. It all goes back to the "mystery" of the Trinity. When Jesus was on the cross, He quoted Psalm 22 (Matthew 27:46; Mark 15:34). This was a psalm of David, but it was a Messianic prophecy as well. The entire psalm contains remarkable predictions by David concerning the coming Messiah. So, one of the reasons He called God "my God" was to fulfill the prophecy of the psalm.
At the moment of His death on the cross, Christ was experiencing the abandonment and despair that resulted from the outpouring of divine wrath upon the sin that He bore. This was the price He paid to redeem His church–all who would ever believe in Him–and He paid it in full. At the cross, Jesus in His humanity voluntarily surrendered His will to the Father in order to finish the task for which He came into the world. In the same way, He voluntarily emptied Himself of certain aspects of His deity when He came to earth as a man. In some way we can’t fully understand, God the Father turned away from God the Son for that moment, and Jesus died a very lonely death.
There are other places He calls God His God. In John 20:17 and Revelation 3:2,12, Jesus calls God "My God." Why would God call Himself "My God"? It has to do with Christ’s relationship to His Father. Even though Christ is the eternal God Himself incarnate, He is still a different person from the Father. As a man and as man’s representative (Son of Man), Jesus’ person was dependent on the Father and, like us, looked to the Father for strength, guidance, wisdom, etc. Therefore, God the Father was the God of Jesus. The Father is the God of the Son, but it doesn’t imply inferiority, only a difference in roles. Please also read our article on the Trinity.