Both phrases are correct but the use of these phrases depend on the context. Imagine you're in a party and you have to work or do some homework for the next day. You will normally use:
Tengo que irme (because I have to work!)
Now imagine you feel kinda sick in the party or maybe you saw your girlfriend cheating on you. You won't feel confortable in that party so you will use:
- Necesito irme (because I don't want people see me crying!)
- Necesito irme (I need some fresh air)
So you see, the last ones are something like "I need the get out of this place". And yes the translations are correct:
- I have to go — Tengo que irme.
- I need to go — Necesito irme.