Yes, you must switch terminals. Take the skyline train. The skyline has an airside part for transfer passengers where you do not need to leave the secure area. See
https://www.frankfurt-airport.com/en...ng-at-fra.html . Just follow the signs to Terminal 2 D/E and skyline.