Go to Edit -> Preferences -> SQL Editor and there you’ll see:
DBMS connection keep-alive interval (in seconds): 600
DBMS connection read time out (in seconds): 600
DBMS connection time out (in seconds): 60
The DBMS connection keep-alive interval means how often Workbench sends keep-alive request to the server to keep the connection alive.
Since 5 minutes == 300 seconds,
set DBMS connection keep-alive interval < 300 (e. g. 250)
It will mean “send keep-alive request every 250 seconds”. Click OK.
Then quit MySQL Workbench and relaunch it to make the changes take effect.
If you use Standard TCP/IP over SSH connection method, it’s also can be helpful to configure ssh ServerAliveInterval as well.