Carlsberg has agreed the sale of one of its breweries in Germany.