Is it "two oatmeal pies a day keep the doctor away" or "two oatmeal pies a day keeps the doctor away"?
Either one could be correct.
This question highlights an interesting feature of English called notional agreement. Here's an excerpt from Merriam Webster:
Most English speakers know the basic rule of subject-verb agreement: a singular noun takes a singular verb, and a plural noun takes its corresponding plural...But there are times when the determination for what counts as "agreement" is not as obvious, because what sounds like a singular noun is really plural, or what sounds like a plural noun is essentially singular. This concept is known as notional agreement, otherwise known as notional concord or synesis.
Simply put, notional agreement occurs when the agreement between a subject and its verb (or, in some instances, a pronoun and its antecedent) is determined by meaning rather than form.
A clear example of notional agreement is "peanut butter and jelly is my favorite sandwich." Peanut butter and jelly looks at first like a plural subject, but the intended meaning of the sentence is something like: [the combination of] peanut butter and jelly is my favorite sandwich.
Other examples cited in that article include, "two plus three makes five" => [the sum] two plus three makes five, "ten dollars is the cost of admission" => [a value of] ten dollars is the cost of admission.
So what about your "two pies"?
To answer the question, we'd need to know whether it was the two pies separately, each one working on its own, that kept the doctor away, or whether the pair of pies, as a unit, kept the doctor away. We can't definitely decide which of those is the case, since this is metaphorical language. I happen to read this statement as [Eating] two pies a day keeps the doctor away, and thus, I'd use the singular form, keeps.
If we're describing what native speakers say, we'd have to say that both versions are acceptable.
It's possible to understand "two oatmeal pies a day" as a singular "prescription for health" and then use the singular verb. Sometimes semantics trumps the grammatical number of the noun.