No, you don't have to connect it forever.
You just have to proceed to stake it as on their documentation page information(
https://docs.pancakeswap.finance/products/yield-farming/how-to-use-farms), then just let it do the work. Staking on PancakeSwap in a sense doesn't similar to running a 24/7 staking node, the underlying smart contract will do its job after you approve to farms CAKE-BNB.