Molecules such as these require a few things to form. First of all, it needs to be a slightly cooler environment than what you would find in stars. In fact, TiO absorption is a main feature of the visual spectra in cooler stars, or those with spectral class M. (So if you ever find yourself having to classify stellar spectra in your astronomy classes, that's a dead giveaway!)
Molecules in the gas phase can also build larger and larger molecules and, eventually, dust grains that play an important role in star and planet formation. TiO2 can then act as a catalyst for making larger and larger molecules in the environment around stars. We know from decades of radio observations that interstellar space is full of molecules, even simple amino acids that may have later formed the basis for life.
PHOTOS: ALMA: New Jewel of the Atacama Desert
In addition, molecules are excellent tracers of the physical conditions of the gas clouds in which they reside. Molecules are detected through their spectral lines, that is, the emission in certain wavelengths or "colors" that they give off as they change their energy state. In this particular discovery, the molecules were changing their rotational state, or how they spin. From what we know of these molecules and their physical behaviors, the astronomers were actually able to determine how much TiO and TiO2 is in the environment.
Such interstellar chemistry is a rich area for exploration. No test tubes or flasks are needed, but radio telescopes that measure millimeter and submillimeter wavelengths such as the SMA. Its successor, the Atacama Large Millimeter/Submillimeter Array, or ALMA, will be much more sensitive and have excellent spectral capabilities that will allow astronomers to detect molecules in space that they haven't even begun to guess at.
So don't be so surprised to find sunblock around a star, as there are many more weird and wonderful substances to be discovered in space.
Images: Top - The dusty nebula surrounding VY CMa. Credits: Molecule symbols: CDMS/T. Kamiński, Background image: NASA/ESA and R. Humphreys (University of Minnesota); Bottom - The SMA interferometer where the discovery of the new molecules in VY CMa was made. Credit: N. Patel/SMA This research was published in Astronomy and Astrophysics, and a preprint is available on arXiv.