Your ancestor, Colonel Charles Jay Foster was reported a retired jeweler at the time of his death. [See the earlier posted San Francisco funeral home reference]
He married Mina Bauer on Saturday, March 23, 1889, in San Francisco, California. Sausalito News, Friday, March 29, 1889, p. 3, c. 6.
The engagement was announced in October, 1888; Charles was then the purchasing agent in Europe for Geo. W. Shreve & Co. See, Sausalito News, Friday, October 12, 1888, p. 3, c. 2.
Geo. ... Shreve & Co., aka Shreve & Co., is reported by today's Wikipedia as the "oldest commercial establishment" in San Francisco.
Charles J. Foster appears in various San Francisco Directories between 1889 (the time of his marriage) and 1880 (the date of the census entry about which you have inquired). (He probably appears in all the years, a few are listed below.)
At San Francisco in the 1880 U.S. census is one one Chas. J. Foster, age 30 [indexed as 20], b. New York. Link here to the FS index; partial snippet below from Ancestry. This Chas. J. Foster is enumerated as a lodger in what seems a boarding house. (Page and image is not in good shape; other than to say it doesn't seem to be "Pine," I can't make out the street.) Occupation is "merchant"; entry remarks that he is "out of the ?city."
SFgenealogy.com has other San Francisco information and directories online. There is probably a better way to navigate to it, but I used their page, "Index of ... Directory." to view images from Langley's 1879 San Francisco Directory.
- image 71 is the directory title page.
- image 403 (actual page is 333) has entry, Charles J. Foster, salesman, George C. Shreve & Co., r. 1122 Pine.
And ... they have the 1878 directory.
- image 86 is the title page
- image 414 (actual page is 330) has entry Charles J. Foster, salesman Anderson & Randolph, dwl NE cor Kearny and Post.
- (I couldn't quickly find an ad for Anderson & Randolph in the 1878 directory, but did find an ad for them in the 1879 publication. See the entry here: "Randolph & Co.: Jewelers," said "Successors to "Anderson & Randolph."
I guess this is a long way of saying your Charles J. Foster was probably enumerated at San Francisco in 1880; he may be the man in the census entry provided. He likely resided there at least by 1878.
Your Charles J. Foster does not seem to be the man in 1880 stationed at Wyoming.
Would think it is possible for you to keep "inching" him back to see when he stops appearing in the San Francisco directories.
Wikipedia, "Colonel (United States)" suggests this military rank, "became rare" in the period after the Civil War; also "many brevet colonels were appointed again during the Spanish American War, prominent among them Theodore Roosevelt and David Grant Colson."