In informal English usage, "guinea pig" means the subject of an experiment. In current laboratory research on animals, mice and rats are more commonly used rodents than guinea pigs; however, in the past the guinea pig, or cavy, was widely used in scientific research. The biggest boom in their use came in the 1880s after two discoveries in bacteriology: in 1882 German bacteriologist Robert Koch used guinea pigs to discover the bacterium that causes tuberculosis because mice and rats did not develop obvious symptoms, and in 1884 German bacteriologist Friedrich Löffler (or Loeffler) discovered that mice and rats were not very susceptible to diphtheria, but guinea pigs are extremely sensitive to it. In fact, guinea pigs have an immune system much more like that of humans than most rodents, and so were the most widely used test animal in the tracking down of disease germs in the late 1800s and early 1900s.

Guinea pigs are also one of the few lab animals which require vitamin C in their diets rather than being able to synthesize it in their bodies; this led to the discovery of vitamin C in 1907. They are still used to study body processes which require vitamin C. They also need to take in folic acid, thiamine, arginine and potassium, making them useful in other nutrition studies. NetVet Veterinary resources cites some additional features which make guinea pigs useful in research:

Overall, guinea pigs have contributed to 23 Nobel Prizes in medicine or physiology. Guinea pig studies led to the discovery of the hormone adrenaline and helped develop replacement heart valves, blood transfusions, antibiotics and asthma medicines, as well as vaccines for diptheria and tuberculosis. Given these past achievements, it is somewhat surprising that they now seem to make up a very small percentage of laboratory experimental animals, between 1% and 2% depending on which source is used. This decrease seems to stem from new allergy tests for skin sensitivity and other things which formerly used guinea pigs and now use mice, or no longer use animals. And of course, this animal is not like humans in every way; Howard W. Florey, who worked with Alexander Fleming in refining pencillin, said in a speech in 1953:
Mice were used in the initial toxicity tests because of their small size, which economised the precious material, but what a lucky chance it was, for in this respect man is like the mouse and not the guinea pig. If we had used guinea pigs exclusively, we should have said that penicillin was toxic...This perhaps carries with it the suggestion that the dramatisers of science who wrote for the public press might with some appropriateness refer to "human mice" rather than to "human guinea pigs" in the future.
The Oxford English Dictionary notes the first written use of "guinea pig" in its generic test-subject sense in 1913 (by George Bernard Shaw). It became widely known enough that in 1933 consumer researchers F. J. Schlink and Arthur Kallet wrote a book called 100,000,000 Guinea Pigs, and by 1953 Dr. Florey gave the above comment on the inaccuracy of the usage. By 1970 even a Czech author, Ludvík Vaculík, titled an anti-Communist book The Guinea Pigs (Morčata in Czech), showing that the usage is not limited to the English-speaking world.

Sources:
Allen, Arthur. Vaccine: the Controversial Story of Medicine's Greatest Lifesaver. New York: W.W. Norton & Company, 2007.
http://www.rds-online.org.uk/pages/page.asp?i_PageID=1264&i_ToolbarID=5
http://www.medterms.com/script/main/art.asp?articlekey=34369
http://www.britannica.com/eb/article-9048742/Friedrich-August-Johannes-Loffler
http://www.answers.com/topic/guinea-pig?cat=health
http://netvet.wustl.edu/species/guinea/gpmodel.txt
http://research.uiowa.edu/animal/?get=g_pig
http://www.straightdope.com/columns/011012.html
http://www.worldwidewords.org/qa/qa-gui1.htm
http://www.fbresearch.org/education/MythPenicillin.htm
http://www.guardian.co.uk/science/2005/aug/25/thisweekssciencequestions1
McMurray, David N. "Guinea Pig Model of Tuberculosis," Tuberculosis: Pathogenesis, Protection, and Control ed. Barry R. Bloom. ASM Press, 1994. accessed through books.google.com