Hello @Pavel A.,
I invite you to take a look at this X-CUBE-DBANK-F7, this firmware is intended to describe the STM32F7 Flash-memory dual-bank capabilities.
So indeed, CubeProgrammer could detect the dual bank mode through User Configuration OB nDBANK, which is not present in STM32H7 for example. The base address of the Flash sectors and sizes should be defined by the user in the main.h.
Second, you don't have to disconnect and connect the board to flash data. All you need to do is to check or uncheck nDBANK OB to specify the FLASH mode: single bank or dual bank and apply. Then flash the code depending on the specified FLASH mode.
Just one more thing, it is recommended to execute code from SRAM or use bootloader to avoid reading corrupted data from Flash when the memory organization is changed any access (CPU or DMAs) to Flash memory should be avoided before reprogramming.
I suggest to take a look at the RM0410 section 3.3.6 Switching from single bank to dual bank configuration for further details