It's a potential minefield – particularly so if the property is leasehold, as most flats are in England and Wales (though not in Scotland). Houses are generally freehold.
Most leases specify that flats in the block in question must not be used for illegal or immoral purposes.
Knowingly renting a flat to a brothel-owner would contravene both requirements. Knowingly renting a flat to a solo prostitute would be immoral, though probably not illegal. (However Daviemac suggests that a landlord could step over the line into illegality if he charged above the market rent because he knew his tenant was a prostitute, since he would then be benefiting financially from her work.)
In extreme circumstances – although instances are exceptionally rare – the leaseholder (that is, the "owner" of the flat) may have his flat forfeited if he allows it to be used for illegal or immoral purposes, with ownership reverting to the freeholder.
There was an instance two years ago. The freeholder tried to obtain forfeiture and was initially successful. However the decision was then reversed on appeal because the Upper Tribunal decided that the freeholder had been unable to prove that the leaseholder had
knowingly allowed the premises to be used as a brothel.
The matter was then referred back to a fresh First-tier Tribunal. I haven't been able to establish what the final decision was, because I couldn't find a report of what happened at the second First-tier Tribunal.
Links:
External Link/Members Onlyand
External Link/Members Only