Scientists say they have worked out how teeth become sensitive and hurt with cold food and drinks.