This colorful phrase is used to express surprise. I found another board where this question was answered and have pasted the link and text of the answer below.
I wonder if you've been reading _Pollyanna_ by Eleanor H. Porter because the phrases appears in that book a few times.
http://www.phrases.org.uk/bulletin_board/55/messages/588.html
I think it started with the simple expression "My stars!" in which "stars" are used in the astrological sense, thus, roughly, "my fate/luck/destiny". This was expanded for a joke into "My stars and garters!" which is a reference to the regalia of the Order of the Garter, Britain's senior order of knighthood - knights of the Order wear a jewelled star on the breast and a gold-embroidered garter round one leg. "The Star and Garter" is a traditional British pub name, so the phrase would come easily to any British working-class person. "Stockings" is a logical change from "garters", with the advantage of providing alliteration.