A product warranty liability and warranty expense should be recorded at the time the product is sold, if it is probable that customers will be making claims under the warranty and the amount can be estimated. These two conditions are part of the FASB's Statement of Financial Accounting Standards No. 5, Accounting for Contingencies. You can read this pronouncement (which includes a discussion of product warranties) at www.FASB.org/st.
When the warranty liability is both probable and can be estimated, the accountant will accrue in the period of the sale a liability and an expense for the future warranty work. (This matching of warranty expense with the related sales revenue is reasonable, since the warranty could be as important in getting the sale as the product's advertising expense.)
When work is done under the warranty coverage, the warranty liability will be reduced. To illustrate, assume that an automobile manufacturer debits Warranty Expense for $1,000 and credits Warranty Liability for $1,000 in the period that a car is sold. When the car needs a $400 repair under the warranty, the manufacturer will reduce Warranty Liability by debiting the account for $400. (Another account, such as Cash, will be credited for the $400 it remits to the dealer that performed the repair work.) This will leave a liability of $600 for additional repairs during the remainder of the warranty period.