Interesting question. The answer isn't quite as simple as you'd think.
There are actually several possible options that you might come across.
"I usen't to do this"
This is very, very outdated, but you might encounter it in some ancient grammar books. You should ignore it.
"I used not to do this"
Also, quite outdated. You might still see this in formal contexts. You can ignore it.
"I didn't used to do this"
A dangerous one! An enormous number of native speakers believe this to be correct. This is because of the elision that occurs with the 'd' of 'used' (which, unusually, is actually pronounced as a 't' in this context - note the difference between the past simple 'used', pronounced /juːzd/ and the 'used' of 'used to', which is pronounced /juːst) . This 't' merges with the 't' of 'to', so that we can't actually tell whether we're saying 'use to do this' or 'used to do this'. In fact, the last two words of these two sentences are pronounced the same:
"Yes, I used to." ---> /ˈjuːst tuː/
"No, I didn't use to." ---> /ˈjuːst tuː/
Because they both have the same' 't' sound, many people will insist that the negative form is also 'used to'. This is not correct. Take no notice of anyone who tries to correct you.
"I didn't use to do this".
This is the correct form.