When buying the engine, should the seller have given you the v5c in which case you send that to the dvla or does that only apply when you buy the whole car?
The V5 is associated to the car's chassis rather than the engine - it lists the current engine number but doesn't "follow" the engine around so no you wouldn't get the V5 when buying just the engine
How can I ensure the engine isn't a stolen one?
If buying just the engine then all you can really do is take the same precautions you would when buying any other second hand item or component - buy from a reputable seller and check any paperwork you can thoroughly. For more peace of mind you would be better buying a whole car (say a write-off from a salvage yard) and transplanting the engine, that way you can use the donor car's V5 etc to check it isn't stolen. Or, as Solar Mike says buy new from the OEM, but of course that will be significantly more expensive.
If I let the dvla know, then they find the engine belonged to a insurance claimed car(though the engine was intact) after notifying them will my car know be showing as a car which was involved in an accident?
Nope - as above the register that tracks total losses (which things like HPI checks look at) is around the chassis not the engine. It would no more make it show up as a total loss than it would if you installed the wiper blades from a written-off car.
If I did buy a stolen engine(without knowing) and install it, then notified the dvla of the new engine, would they dvla be able to tell it's from a stolen car and would this create any problems for me e.g. engine will be confiscated?
If you can back up that you bought the engine in "good faith" believing it wasn't stolen then you wouldn't be prosecuted for anything - but it wouldn't change the fact that you had no legitimate claim to the engine and the rightful owner would be entitled to it's return. Any monies you had paid out for the engine would be lost.
If you change engine to exactly the same engine, do you need to notify the dvla?
Yes you do - you need to provide them with the new engine number and one of the following:
- a receipt for the replacement engine
- written evidence from the manufacturer
- an inspection report provided for insurance purposes
- written confirmation on headed paper from a garage (if the change took place before you bought the vehicle)
Obviously if you are changing the engine for a different model then there's more you have to provide such as the capacity of the new engine and fuel type if different.