Do I need to upgrade iOS before creating backup to be restored onto new iPhone?
No - you should probably always backup before any upgrade just in case the upgrade fails. I would get a backup as soon as you can in general as well as in specific when you are about to move or upgrade.

The good thing about your situation is the iPhone X and iOS 11 setup assistant will remind you to make a backup of the old device and even let you start the setup and wait for the other backup to complete.

Getting a backup now is good since backups to iCloud and backups to iTunes tend to be incremental so they save several backups and the next backup will just need to save changed data and often completes very quickly.

The only time you might consider upgrading is if you have a really old version of iOS and skipped several major versions. I do like always updating right before a transfer since sometimes minor updates fix issues with setup so you can skip those bugs by updating everything after you have a good foundation backup.