Configuring the computer to boot from the Ubuntu USB stick if it is inserted, otherwise to boot to Windows if it is not inserted can be done by changing the boot priority settings, which is often found under the Boot tab of the computer's BIOS/UEFI utility. The BIOS/UEFI utility can be accessed by pressing the key which is shown on the manufacturer's splash screen when booting. This is the F12 key on many computers. The keys to press, such as F12, F2, Del or Esc, differ on computers from different manufacturers.
When the power button is pressed to start the computer, it will try to boot first from whatever option is listed first in the boot priority section of the computer's BIOS/UEFI utility. If the USB stick is listed first in the boot priority list, it will try to boot from the USB stick first. If the internal hard drive where Windows is installed is listed first in the boot priority list, the computer will boot to Windows.
If the computer can't boot to the first device in the boot priority list because it is not attached, it will try to boot from the second device in the boot priority list instead. If the USB stick is listed first, but it is not currently inserted in the computer, the computer will skip the USB stick when booting and boot Windows from the hard drive instead, assuming that the Windows hard drive is the second device in the boot priority list.