While most long-term investors tend to focus their attention on the stock market, they can sometimes forget that the bond market has a life all its own. Sometimes, bonds do well when stocks do; sometimes not. And as stocks become more volatile, the party may be ending for one segment of the bond market that has enjoyed several years of outsized gains.

All good things must end
Fixed-income investors in general have done well over the past several years, helped partly by a low interest-rate environment and a solid economic backdrop. But high-yield bonds, also known as junk bonds, have posted the greatest gains, recently returning more than some equity indices. For example, the Credit Suisse High Yield Bond Index has posted an annualized 11.8% five-year return through June 30 -- way ahead of the Lehman Brothers Aggregate Bond Index return of 4.5%, and even eclipsing the S&P 500's 10.7% return!

But while junk bonds have partied hearty, odds are good that they'll soon wake up with a hangover. In recent months, junk-bond yields have risen from about 7.5% to 10%, pushing bond prices down. High-yield bond funds are starting to sputter, with the average junk-bond fund down about 1.5% in the month of June alone. That's the worst one-month return this sector has suffered in more than two years. Of course, we shouldn't read too much into just one month of returns, but it's not something to ignore.

Previously, low interest rates had spurred demand for junk bonds, and with good economic conditions upon us, default rates stayed at relatively low levels. Lately, however, demand for high-yield bonds has faltered, with investors pulling more than $1.5 billion out of junk bond funds during June. Many investors are now thinking twice about whether they should even own bonds in this sector.

A warning from a bond guru
Just last week, PIMCO's own Bill Gross warned that potential trouble in the junk bond and subprime mortgage markets could trigger a correction in the equity markets. Gross stated that bond investors were letting private-equity and hedge-fund players take advantage of their uncertainty surrounding junk bonds' stability, allowing these institutional investors to build returns at individuals' expense.

Gross believes that U.S. Treasuries could be influenced by falling junk bond prices, and that stocks may need to be devalued in light of rising junk bond yields. Homebuilders like KB Home (NYSE:KBH) and Beazer Homes (NYSE:BZH) already have junk ratings, while other homebuilders may get downgraded in the near future.

Gross's warning came only days before last Thursday's market plunge, which was indeed precipitated by concerns over the subprime mortgage market. Odds are good that junk bonds may underperform in the future, and the possibility for a further stock market correction remains.

Now for the good news
All is not lost. Happily, most investors need little exposure to junk bonds. Exposure to a broad fixed-income fund is most investors' best bet. This fund should have the option to invest in high-yield bonds, but also the flexibility not to invest in that sector, if the right opportunities aren't present. Few investors should own an entirely separate high-yield bond fund; even if they do, junk bonds should compose a very small percentage of their overall portfolios.

Long-term investors should still allocate a majority of their assets to high-quality stocks or stock-centric mutual funds. But some exposure to bonds is necessary, especially for older investors who need to dampen volatility within their portfolios. Although junk bonds may produce tempting returns, they should only be introduced strategically, and they should almost never account for a large portion of your investment. A high-quality diversified bond fund is your best vehicle for riding out any bumps in the junk-bond market. I bet even Bill Gross would agree with that.

Related articles:

Whether you are interested in bond funds, equity funds, or both, discover which mutual funds are the best of the best. Check out the Fool's Champion Funds newsletter with a free 30-day trial.

Fool contributor Amanda Kish lives in Rochester, N.Y., and does not own shares of any of the companies or funds mentioned herein. The Fool's disclosure policy keeps its junk in the back of the closet.