There is a sign that long-duration gamma-ray bursts (GRBs) originate from the core collapse of massive stars. During a jet puncturing through the progenitor envelope, high energy neutrinos can be produced by the reverse shock formed at the jet head. It is suggested that low-luminosity GRBs (LL-GRBs) are possible candidates of this high energy neutrino precursor up to $\sim {\rm PeV}$. Before leaving the progenitor, these high energy neutrinos must oscillate from one flavor to another with matter effect in the envelope. Under the assumption of a power-law stellar envelope density profile $\rho \propto r^{-\alpha}$ with an index $\alpha$, we study the properties of ${\rm TeV-PeV}$ neutrino oscillation. We find that adiabatic conversion is violated for these neutrinos so we do certain calibration of level crossing effect. The resonance condition is reached for different energies at different radii. We notice that the effective mixing angles in matter for ${\rm PeV}$ neutrinos are close to zero so the transition probabilities from one flavor to another are almost invariant for ${\rm PeV}$ neutrinos. We plot all the transition probabilities versus energy of ${\rm TeV-PeV}$ neutrinos from the birth place to the surface of the progenitor. With an initial flavor ratio $\phi_{\nu_e}^0:\phi_{\nu_\mu}^0:\phi_{\nu_\tau}^0=1:2:0$, we plot how the flavor ratio evolves with energy and distance when neutrinos are still in the envelope, and further get the ratio when they reach the Earth. For ${\rm PeV}$ neutrinos, the ratio is always $\phi_{\nu_e}:\phi_{\nu_\mu}:\phi_{\nu_\tau}\simeq0.30:0.37:0.33$ on Earth. In addition, we discuss the dependence of the flavor ratio on energy and $\alpha$ and get a pretty good result. This dependence may provide a promising probe of the progenitor structure.