You may be able to get a loan to help with your mortgage payments while you are in prison. But, this depends on what benefits you were claiming before you went in and on how long you'll be in prison for. Someone who was living with you may be able to claim help to pay the mortgage if you cannot.
You might not be able to keep your home if you are going to be in prison for a long time, or you can't go back to it because it isn't safe for you or someone else. Talk to the housing adviser in your prison if you want to give up your home.