What is the difference between 公分 and 厘米?
In 1928, the government of the Republic of China introduced the metric system to China (read more). It translated "centimeter" into 「公分」.

Later in 1959, the government of the People's Republic of China standardized the measurement unit in mainland China (read more). It translated "centimeter" into 「厘米」.

So currently some elder people in mainland China still use 「公分」(like my grandparents on both sides), and the younger generation tends to use 「厘米」. For the same reason, Taiwanese would more often use 「公分」.

My advice is to use 「厘米」when you communicate with people from mainland China, and use 「公分」 with Taiwanese (Usually they can understand「釐米」, but it sometimes is confusing and ambiguous thanks to 「公厘」).