When did Jesus realize that He had miraculous powers? Mary asked Him to help at the wedding feast. This somewhat implies that she had seen His wonders before.
John specifically said that turning water into wine at the wedding feast was “the first of his signs” (John 2:11). Thus, Mary would not have seen her Son perform any sort of miracle before. However, she would still have already associated the miraculous with her Son for several reasons. She was told from the beginning that He was the Son of God (Lk. 1:32, 35), and so would naturally conclude He was capable of miracles. Both His birth and His cousin’s birth were completely miraculous in nature (Lk. 1:18, 34-37). Supernatural and miraculous events took place during the time in which He was born (Lk. 2:8-20; 25-38; Matt. 2:1-15).
As to when Jesus realized that He had miraculous powers, the Bible does not specifically say. Several possibilities are given from the Bible. At age 12 He apparently knew that God was His Father (Lk. 2:49). That could have been inherent knowledge due to His being deity (John 1:1, 14) or taught knowledge given to Him by Mary and Joseph (Lk. 2:40, 52). At age 30 He apparently already understood that it was right for Him to be baptized by John, acknowledging that John spoke of Him being superior (Matt. 3:13-15). So perhaps He knew of His deity (and thus knew of His miraculous ability) throughout His life.
It must also be pointed out that at His baptism, the Spirit of God remained on Him without measure and He heard God’s voice call Him His Son (Matt. 3:16-17; John 1:32; 3:34). Having the Spirit without measure implies the ability to perform all kinds of miracles was given to Him at that time (cf. 1 Cor. 12:1-11), so perhaps He knew then.