A pension is a system set up under capitalism in which one pays into with their wages and possibly the employer pays into as well, so when the person retires, they have money saved up to support themselves. Due to capitalism and/or wage labor not existing in an anarchist society, there probably wouldn't be pensions. I don't know what you mean by "isn't allowed to work?" That implies that there's some authority telling this person what they can or cannot do.

the very concept of "pensions" is so steeped in capitalist society that i can not perceive of an anarchist world where it has any relevance whatsoever.

also, as human points out, the phrase "when a person isn't allowed to work anymore" is so authoritarian sounding that it raises serious issues around the question in general.

if, as human also mentions, you are really just asking what happens to folks that are not capable of meeting their own needs, there are a number of questions/answers on this site that address that (try searching the site for terms like "disabled", "elderly", etc - also look at the tags page).

the bottom line for me: it's all about relationships. folks that care about each other, take care of each other (as necessary/desired). no state, laws, contracts or any other coercion necessary.