You are talking about Housing Benefit. You must let the Local Authority know when you go into prison. They will decide whether the benefit is to stop, depending on how long you are expected to be in prison. This is not necessarily the same as the length of sentence because inmates are normally let out after half their sentence or - sometimes - even earlier on a tag.