The context is:
7 On that day, David ordained to give thanks to the Lord by the hand of Asaph and his brethren.
8 "Give thanks to the Lord, call out in His Name; make His exploits known among the peoples. [...]
12 Remember His wonders, which He performed, His miracles and the judgments of His mouth.
13 The seed of Israel His servant, the children of Jacob, His chosen ones.
14 He is the Lord our God; throughout the earth are His judgments.
15 Remember His covenant forever, the word which He commanded to a thousand generations. [...]
20 And when they walked from nation to nation, and from one kingdom to another people.
21 He let no man oppress them, and He reproved kings on their account;
22 "Do not touch My anointed ones, and do not harm My prophets."
The message "do not touch my annointed ones" is addressed to the kings God reproved. Who are they? The medieval scholar Rashi (Rabbi Shlomo ben Yitzchak) explains:
He let no man oppress them: [...] Now if you ask if the reason that the highwaymen and [the people of] the other lands in whose midst they passed did not harm them was that they did not notice them, but if they had noticed them, they would have oppressed them, therefore, it says: “… and He reproved kings on their account,” i.e., they did oppress them, as Pharaoh [did] to Abraham and Abimelech to Isaac, and Laban and Shechem to Jacob, and the Holy One, blessed be He, said to them…
Do not touch My anointed ones, and do not harm My prophets: Concerning Abraham it says (Gen. 12:17): “And the Lord plagued Pharaoh,” and it is written (ibid. 20:3): “And the Lord came to Abimelech in a dream at night and said to him: You shall die, etc.” Concerning Jacob it says: (ibid. 31:24): “And God came to Laban the Aramean in a dream at night, and said to him: Beware, etc.” And further, concerning Jacob, when they came to kill him because they killed Shechem and Hamor, it is written: (ibid. 35: 5): “Then they journeyed on, and the terror of God was, etc.” The Book of Psalms is more explicit, for the psalm does not terminate here, as it is written there (105:16): “He called a famine upon the land,” in order to exile them to Egypt.
According to this interpetation, "do not touch my annointed ones" refers to the patriarchs who were chosen by God for a special covenant. This isn't a direct quote but a reference to several incidents where God intervened, for example in dreams, to warn off would-be oppressors. (Rashi's final statement, about causing a famine, is less clear to me.)