The outbreak of COVID-19 increased global financial risks and economic shocks. Although epidemic risk is on the decline, the likeliness of a similar black swan event occurring in the future cannot be ruled out. In this study, we constructed epidemic search indices using the Google Search Volume Index (SVI) to examine whether investor sentiment regarding the COVID-19 pandemic affected stocks, gold, silver, copper, crude oil, and natural gas. The results reveal that, over the entire epidemic period, energy assets (crude oil and natural gas) were the most “resistant” to epidemic panic, making them suitable for hedging the risk associated with epidemic panic risk. We employed a time-varying parameter structural vector autoregression model with stochastic volatility (TVP-SVAR-SV) to analyze the time-varying contagion effects of epidemic search indices on various asset prices at different points in time. The findings indicate that in the early stages of the COVID-19 pandemic when epidemic panic risk was highest, natural gas prices exhibited the most risk-averse characteristics. Only during the middle to later stages of the epidemic did natural gas prices begin to be positively affected by epidemic panic sentiment. However, during this period, the epidemic search indices show a stable declining trend, indicating a reduction in risk. We observe that natural gas prices only reflected panic sentiment during periods of stability. The results of this study suggest that energy commodities, especially natural gas, are suitable for hedging against unforeseen high epidemic risks. When epidemic risk decreases, profits can be realized and reinvested in assets with a higher contagion effect due to epidemic risks, further benefiting from the rebound in the prices of these assets. In addition to explaining why energy commodities are particularly suitable for mitigating epidemic-related black swan events, we provide a detailed investment strategy for hedging future epidemic risk and further elaborate on how investors should dynamically adjust their portfolios according to the severity of the epidemic and whether it is under control.