Social Security calculates the annual COLA by taking the average yearly change of the Consumer Price Index for Urban Wage Earners and Clerical Workers, or CPI-W, for July, August and September and comparing it to the same period the previous year.
Summary from source