I don't think they are "sure", but the weights are based on the [American Consumer Expenditure Survey][1] which has a big sampling size, carefully chose sampling frame, professionally executed sample gathering, and experts crafting questions and collating the data.  

> <h1>How is the CPI market basket determined?</h1>
> 
> The CPI market basket is developed from detailed expenditure
> information provided by families and individuals on what they actually
> bought. For the current CPI, this information was collected from the
> Consumer Expenditure Surveys for 2011 and 2012. In each of those
> years, about 7,000 families from around the country provided
> information each quarter on their spending habits in the interview
> survey. To collect information on frequently purchased items, such as
> food and personal care products, another 7,000 families in each of
> these years kept diaries listing everything they bought during a
> 2-week period.
> 
> Over the 2 year period, then, expenditure information came from
> approximately 28,000 weekly diaries and 60,000 quarterly interviews
> used to determine the importance, or weight, of the more than 200 item
> categories in the CPI index structure.

[Consumer Price Index Frequently Asked Questions (FAQs)][2] 

> Consumer expenditure data supplied by the CE Survey are a critical
> component of the CPI, as they are used to estimate weights for the
> CPI’s consumer goods and services classification structure used in the
> calculation of the CPI. In the construction of the CPI, four distinct
> functional uses of CE Survey data are made: (1) to estimate biennial
> expenditure weights, (2) to estimate monthly expenditure weights, (3)
> to calculate the probability that an item’s price will be included in
> the CPI calculations, and (4) to allocate expenditure estimates
> between more-broadly defined expenditure categories from other survey
> sources.

[Research highlights of the Consumer Expenditure Survey redesign][3] 

Page 6 of BLS Handbook of Methods, April 1997, [Chapter 16: Consumer Expenditures and Income][4] has a nice, detailed description of how "The estimation of population quantities of interest, such as the average expenditure per consumer unit on a particular
item category, is achieved through the use of weights." Be sure to check that out too. 


  [1]: http://www.bls.gov/cex/
  [2]: http://www.bls.gov/cpi/cpifaq.htm#Question_6
  [3]: http://www.bls.gov/opub/mlr/2013/article/ce-survey-redesign.htm
  [4]: http://www.bls.gov/opub/hom/pdf/homch16.pdf