No, you don't need to play DnD to enjoy Baldur's Gate 3

Dungeons & Dragons is responsible for more videogames than you'd think. Obviously Baldur's Gate 3 springs to mind, but when you think deeper, almost any RPG that uses a baseline stat system evolved from those early tabletop roleplaying games. Many of the earliest text-based RPGs played on old CRT screens took inspiration from DnD or were even set in Faerûn-like worlds.
RELATED LINKS:
Baldur's Gate 3 Minthara companion guide
Baldur's Gate 3 Wyll companion guide
Baldur's Gate 3 Karlach companion guide