Regarding Sectumsempra, specifically - what magic can do, magic can undo.
(Disclaimer: obviously that isn't true of everything in the Harry Potter universe. In fact, the point is often made in The Deathly Hallows that some wounds inflicted by Dark Magic can't be cured. George's ear, for example, cannot be replaced. I simply bring up that nice old quote to mark the difference between Malfoy's wounds and Dobby's. Besides, when Harry used Sectumsempra against Malfoy, he was slashing at him with a spell he'd never practised before and Malfoy's wounds don't seem to have been overly deep. Snape - an extremely skilled wizard - then arrived immediately and was able to counter wounds inflicted by magic, with magic. Dobby took a knife through the chest.)
Regarding Dobby's death specifically, he had a pretty serious stab wound through vitals and had then travelled by Apparition. He's still biological, don't forget that. Assuming the damage was reversible, they had seconds - if that. Don't confuse magic (esp. the magic of Harry Potter) with invincibility.
Now Harry was not much good at healing spells as we know:
It was stupid, pointless, irritating beyond belief, that he still had four days left of being unable to perform magic ... but he had to admit to himself that this jagged cut in his finger would have defeated him. He had never learned how to repair wounds and now he came to think of it - particularly in light of his immediate plans - this seemed a serious flaw in his magical education.
Harry Potter and the Deathly Hallows - p.19 - Bloomsbury - chapter 2, In Memoriam
And on top of this, he was panicking.
Maybe somebody at Shell Cottage could have saved him, but by the time help arrived it was already too late. It takes Harry a while to notice that the elf is injured:
'Dobby, is this Shell Cottage?' he whispered, clutching the two wands he had brought from the Malfoys', ready to fight if he needed too. 'Have we come to the right place? Dobby?'
He looked around. The little elf stood feet from him.
'DOBBY!'
Harry Potter and the Deathly Hallows - p.385 - Bloomsbury - chapter 23, Malfoy Manor
And then he does call out for help:
'Dobby - no - HELP!' Harry bellowed towards the cottage, towards the people moving there. 'HELP!'
Harry Potter and the Deathly Hallows - p.385 - Bloomsbury - chapter 23, Malfoy Manor
But it really doesn't sound like anybody else got there in time. And that's - again - assuming they were capable of doing anything. Healing spells are clearly not on the syllabus at Hogwarts (at least, not in any classes Harry took and he took all the classes in which they would seem to fit). While Madam Pomfrey and the Healers of St. Mungo's seem extremely powerful and while Tonks is able to fix Harry's broken nose - we also see that Hermione doesn't feel confident attempting to heal Ron's wounds when he gets splinched, for instance.