Theoretically, it is possible to use electricity produced from photovoltaic (PV) solar electric panels to heat water for showers & baths, using an electric immersion heater.
If you only have electricity to heat your water anyway, then this could be worth doing (although you could also consider solar water heating, see below).
However, the majority of homes use mains gas for heating water, and in these cases diverting electricity to replace gas may not actually be the best way to make use of PV system output, as it will not reduce carbon emissions as much as exporting the electricity.
In the UK, mains electricity is still mainly produced by coal and gas fired power stations, and is very 'carbon-heavy' in terms of carbon dioxide (CO2) emissions. Using one unit of mains electricity will lead to emissions of about three times as much CO2 as using one unit of mains gas in a modern boiler. For those with oil or LPG fired heating, CO2 emissions per unit will be about half as much as mains electricity.
In fact, PV panels will be producing electricity during peak demand times (the middle of the day) when the coal power stations (the dirtiest and most carbon intensive option) are often used to produce peak electricity.
Therefore, to have the biggest environmental impact, electricity from PV panels should be used for purposes where it directly replaces grid electricity, not to replace these heating fuels.
If you use what PV electricity you can to power electrical appliances (such as using the washing machine when it is sunny) and let any excess flow into the grid, it will replace electricity from fossil fuel power stations - as somewhere a power station will burn less fuel. This will yield much better carbon dioxide savings than if you try to store the electricity, or use it to replace heating fuel.
Using about 1000kWh of PV output per year to heat water instead of using mains gas will save about 200kg carbon dioxide emissions. Whereas letting that electricity flow out into the grid to replace electricity from power stations will save about 600kg carbon dioxide (but actually more than this at many peak times). So exporting PV electricity instead of heating water gives much greater carbon saving per year, and many tonnes of carbon savings over the lifetime of the PV system.
Mains electricity also costs three times as much per unit as mains gas and twice as much as oil/LPG, so the financial savings from replacing gas are far smaller than replacing electricity use.
Remember that you get the feed-in tariff (FIT) for everything that the PV roof generates, irrespective of whether you use it in the house or not. The small wholesale tariff you get for exported electricity is additional to the feed-in tariff. If the electricity you export to the grid is actually metered (as it is likely to be once smart meters are installed more widely), then using the electricity to replace gas instead of exporting it would not actually save anything financially - as gas costs about the same per unit as the wholesale export rate for PV electricity (just under 5p).
Also, before saving any money you need to first recoup the cost of the unit used to divert electricity to the immersion. If you are able to divert 500 units of electricity per year, then you might save about £30 on gas (at about 6p per unit). If the diverter unit costs £300 then it would take 10 years to recoup the installation cost. The lifetime of the diverter unit will also be an important factor here. If you can divert more electricity than this, and/or the unit is cheaper, then the payback will improve. If a unit has its own battery, then you need to factor in replacement battery costs as well.
PV has become much more financially attractive in recent years due to FITs. However, the Renewable Heat Incentive (RHI) has been much delayed, but is now available and makes it more attractive to install domestic solar water heating systems, which are in principle a more efficient way to make hot water.
Turning sunlight into heat is easier than turning it into electricity, which means that dedicated solar water heating panels or tubes are a more efficient way to produce hot water than PV panels.
Using a solar water heating (SWH) system, you will only need about 1 square metre (1m2) of panel per person to meet the hot water demand in summer, so maybe 3 to 4m2 for an average house. Using PV, you'd need about half of the daily summer output of a 3.5kW (25m2) PV system to heat a cylinder of water - so about 3 or 4 times as much roof area dedicted to water heating. If possible, having both PV and SWH makes the best use of available roof area, and the new RHI scheme should make this more financially feasible now than in the last few years.
To illustrate the overall carbon savings from a given roof: a SWH system (less than 5m2) could yield 1200 to 1500 kWh of heat, with about 20m2 of PV giving about 2500kWh of electricity - so approaching 4000 kWh of zero-carbon solar energy in total. Whereas 25m2 of just PV gives about 3000kWh.