Short answer. From the moment the testator dies. Article 945 lets the legatee of a periodical pension petition the court for the first installment upon the testator's death, and for each later one at the start of every period. What is more, once a period has begun, that payment is not returned even if you die before the period ends.
What the law says
the legatee may petition the court for the first installment upon the death of the testator, and for the following ones which shall be due at the beginning of each period
Civil Code, Article 945 — Periodical Pensions. Read the full provision →
What the law says
such payment shall not be returned, even though the legatee should die before the expiration of the period which has commenced
Civil Code, Article 945 — Periodical Pensions. Read the full provision →
The first installment falls due at death
Where a will leaves you a recurring allowance — Article 945 speaks of a periodical pension, or a certain annual, monthly, or weekly amount — the timing rules are generous to you. For the first payment, you do not wait out a full period. The article says the legatee may petition the court for the first installment upon the death of the testator. The pension is treated as running from the death itself, so you can claim the opening installment straight away rather than being told to wait a month or a year before anything is owed.
Later installments fall due at the start of each period
After the first, the pension keeps coming, and the law fixes when each one is claimable: the following installments are due at the beginning of each period. So a monthly allowance is claimable at the start of each month, a yearly one at the start of each year, and so on. You are entitled to the money up front for the period, not only after you have lived through it. This front-loaded timing runs for as long as the pension the testator created is meant to last under the terms of the will.
A started period is not clawed back
Article 945 protects a payment once its period has begun. Such payment shall not be returned, even though the legatee should die before the expiration of the period which has commenced. If you claim the installment for a period and then die partway through it, your estate keeps the whole of that payment — the estate that owes the pension cannot demand a refund of the unused portion. The installment is earned in full at the start of the period, which is exactly why it is claimable up front and why nothing is prorated back when the beneficiary dies mid-period.
Claiming through the estate proceeding
Note that the article frames the claim as a petition to the court, because a pension under a will is paid out of the deceased's estate while that estate is being settled. You assert your right to each installment within the settlement proceeding rather than simply demanding cash from an heir on your own say-so. The pension binds the estate and, through it, the heirs charged with satisfying the will. What the article does not do is create an allowance where the will made none — it governs how and when a pension the testator actually left is claimed.