Tal Danino, a researcher at the Massachusetts Institute of Technology (MIT), described how he programmed the bacteria with genetic code.
The system could be developed to identify other cancers, he said.
So far the research has only been tested on mice.
The mice are fed pre-programmed probiotic bacteria – a similar type to that found in some health-promoting yogurts.
The bacteria produce enzymes when they encounter a tumour which will, in turn, change the colour of urine.
So far, the system has proved accurate at detecting liver cancer.
“Liver cancer is hard to detect, and there really is a need for new technology to help spot it,” Mr Danino told the BBC ahead of his talk.
Mr Danino was the first of 21 Ted fellows – young researchers engaged in cutting-edge work – chosen each year by the non-profit Ted organisation. Their five-minute speeches kick off the conference which, for the second year running, is being hosted in Canada.
“There are more bacteria in the body than there are stars in the galaxy,” Mr Danino told the Ted audience.
“It is a fascinating universe in our body and we can now program bacteria like we program computers.”
But the intersection between biology and computer is still at a “very early stage”, he said.
Bacteria may be particularly useful in the continuing battle against cancer.
Studies have shown that there are often large concentrations of bacteria inside tumours, especially intestinal ones, with some experts suggesting that the bacteria are hiding in tumours because they are places where they cannot be attacked by the immune system.
The next stage for the work Mr Danino is doing is to use the programmable bacteria to detect a range of other cancers and, perhaps eventually, offer treatments.