There is not a blanket prohibition on the practice you describe, which economists would call "age based price discrimination", although there could conceivably be some set of facts in which this is the case.
In economics, "price discrimination" is the practice of finding ways to charge more for the same good or service, for someone who can afford to pay more, and to charge less for the same good or service, for someone who can afford to pay less, and a substantial share of all business practices that superficially seem weird exist in the economy as a form of price discrimination.
This is why there are "happy hours" (people who can take early afternoons off are often more price conscious in addition to fixed costs of the business being ameliorated when volume is higher), matinee pricing at movie theaters, Tuesday afternoon discounts on oil changes, weird pricing for commercial flights, and so on. It is also why, for example, most wine producers make many kinds of wine at different price thresholds even though economies of scale would make it more cost effective to produce just one of each kind of wine.
Certainly, there is not an obligation for the price charged to be proportional to or reflect the costs of product a good or service, although there are certainly goods or services, like all you can eat buffets, or life insurance, where both cost and willingness and ability to pay are related to age.
For example, movie theaters and restaurants frequently have discounts for kids and seniors. The example you suggest is more extreme, but conceptually, really isn't any different.
On the other hand, some kinds of merchants, like utilities, typically have their prices comprehensively regulated and so can only do this with express government approval.
In the example you suggest, you'd expect it to be an attempt to capture the greater ability and/or willingness of older people than younger people to pay.
Law is very context specific and rarely follows strict general rules, so it is hard to answer this question accurately in the abstract. Even when there are regulations of age discrimination they tend to be very specific to particular industries and circumstances.