Martinez struck inside two minutes before Domenico Berardi equalised, but Lukaku gave Inter breathing space with a powerful strike and a penalty before half-time.
Antonio Conte's side held on in a nervy finish to the game as the home side pressed for a remarkable equaliser.
"We did everything right in the first half and should have scored more in the second," Lukaku told sports streaming service DAZN.
"Once it goes to 3-1 and 4-1, it ought to be over. The positive we take is that we got the three points, but we need to defend better than that."
The result leaves Inter in second place on 21 points, one behind champions Juventus and four clear of Atalanta in third.
Conte's side had a perfect winning record in Serie A until a 2-1 home defeat to Juventus before the international break saw them lose top spot.
Sassuolo have caused big problems for the Milanese club in recent seasons and, going into the game, the hosts were unbeaten in their last five games in this fixture.
The home players were handed extra motivation by moving scenes before kick-off as tributes were paid to former club owner Giorgio Squinzi, who died at the start of October.
However, Sassuolo were behind within two minutes as Martinez curled a shot into the corner.
Berardi levelled with a well-taken finish from a tight angle before both sides had goals disallowed, Inter for a foul by Lukaku and Sassuolo for offside.
Lukaku turned his marker and fired past goalkeeper Andrea Consigli to restore Inter's lead and he was on target again with a penalty after Martinez was dragged down in the area.
The result looked beyond doubt when the Argentina international notched his second from the penalty spot after a foul on Nicolo Barella.
But substitute Djuricic quickly pulled one back before his fellow replacement Boga cut the visitors' lead to a single goal with nine minutes remaining.