If these thoughts are of repetitive nature and beyond your control you might be suffering from a condition called OCD...a detailed evaluation will be needed
Next Steps
consult Psychiatrist and start treatment
Health Tips
good medicines and therapies are available for control of this condition and so you must not get disheartened and not think of harming yourself...