Actually, Law had been badly injured to finish Doffy off on his own. Though for the recent chapter, Law by chance had an adequate time of resting and some recovering period thanks to Luffy who previously kept on carrying him around before they met Doffy at the palace. Law caught Doffy off guard by revealing himself as a D and managed to hurt him a little, and Doffy was being careless in the end when he got stabbed by 'Injection Shot' from Law.
Still, Doffy would be so mad he might beat Law furiously after this. Law's stamina would be drained down, since his power had limit. Knowing Law as a D too, that alone could trigger an unpleasant act of Doffy. By the time Luffy got back to where Law n Doffy were, Law might be passed out or beaten up too much. Probably one of the reasons why Oda separated Luffy and Law for a while there.
I bet Luffy vs Doffy as the final fight for this arc rather than Law vs Doffy. It had always been such pattern in several arcs before. Luffy would be usually distracted by other foes before he could get to the leader of the villain. Once Luffy randomly chose his opponent, that said opponent was a dead man for sure, and conveniently, every villain he chose was the strongest one among others without him knowing it.