“Rava bar Machsseya said in the name of Rav Chama bar Gurya in the name of Rav: One who gives a gift to another must inform him” (Shabbat 10b).
As the Tosafists (Shabbat 10b, s.v. hanoten) note, this law applies only if the gift is given as a demonstration of friendship and love. To anonymously give such a gift would be counterproductive, preventing greater closeness between people. However, a gift that is liable to cause embarrassment, such as charity funds, should be given anonymously.