For WSL2, the easiest solution, IMHO, is to use the mDNS name that WSL assigns to the Windows host adapter. This is <computer_name>.local, where <computer_name> is your Windows computer name, which is also, helpfully, the default hostname for WSL.
As a result, from Bash:
export WINDOWS_HOST=$(hostname).local
ping $WINDOWS_HOST
For many services, you will need to make sure the Firewall port is also open, since the WSL2 network is separate from the Windows host. This can be done as mentioned in @Kiruahxh's answer.
Also note that this will fail if you have disabled the WSL2 resolver via /etc/wsl.conf.
Side-note 1:
This question seems specific to WSL2, as under WSL1 just using localhost should work.
Side-note 2:
A very recent (at the time of this answer) change to WSL2 is that it will now try to reuse the same IP address after a reboot. This should alleviate many of the concerns mentioned in other answers around having to make certain changes after every reboot. However, to be as deterministic as possible, I still prefer methods which do not rely on the assigned IP address itself, but rather a known name.