Pine Wilt Disease (PWD) is a devastating pine tree disease characterized by rapid onset, high mortality rate, quick spread, and difficulty in control. Plant microbiome plays a significant role in the development of PWD. However, the endophytic microbial communities of Pinus koraiensis infected by pine wood nematode (PWN) Bursaphelenchus xylophilus remain largely unexplored. In this study, we analyzed the structural changes of endophytic communities of P. koraiensis after infection by the PWN using high-throughput sequencing technology. The results showed that the community structure underwent significant changes as the degree of PWN infection intensified. The diversity and abundance of endophytic fungi in P. koraiensis increased, while those of endophytic bacteria in P. koraiensis decreased during the infection process. Meanwhile, the abundance of some dominant microorganisms has also changed, including species such as Graphilbum and Pseudoalteromonas. Functional prediction analysis showed that the functional composition of endophytic fungi in P. koraiensis was significantly different across the development of PWD, while the composition of endophytic bacteria remained essentially similar. The results indicated that PWN infection had a significant impact on the structure, diversity, abundance, and functional gene composition of endophytic microbial communities in P. koraiensis, and most of the main endophytic microbial groups tended to coordinate with each other. This work provides a better understanding of the changes in endophytic community structure and function caused by PWD infection of P. koraiensis, which may benefit the exploration of potential endophytes for PWN biocontrol.