My informant heard this proverb in Lebanon, his home country. He did not recall the first time he heard it or who he heard it from. He said it is simply an Arabic folk saying that he picked up from friends and family.
This is not the first proverb I have heard that speaks of onions and garlic as aphrodisiacs. Unfortunately, my informant was uncertain of the exact meaning of the second line of the saying. It could mean that eating onions causes one to lose his erection, or that onions cause poor memory. My reaction was to interpret “forget it” as something like “it won’t be going away for days.” In effect, “garlic works, but onions work better,” was my immediate interpretation. On the other hand, it could be a mnemonic (much like our “yellow on black, venom lack; black on yellow, kill a fellow”) for remembering which of the two related herbs is the one that does the trick. As it rhymes in Arabic (Toum, bikoum, Basal, hasal), the proverb incorporates an element of appropriateness, one of the features of most any joke; and obviously, the proverb is for humor and entertainment rather than any kind of edification or instruction.