Mohamed Amoura netted twice – taking his goals tally in the qualifying campaign to eight – while captain Riyad Mahrez, the former Manchester City star, also scored.
Victory for Algeria advanced them to an unassailable 22 points with one match still to play in group G, and it will be their fifth World Cup finals appearance in all after last appearing at the 2014 tournament in Brazil.
The top team in each of the nine continental groups qualifies automatically for the finals in Canada, Mexico and the US, as Algeria join the already qualified Morocco, Tunisia and Egypt to ensure a strong north African representation in 2026.
Amoura handed Algeria a seventh-minute lead when Mahrez's cross was missed by striker Baghdad Bounedjah but found the Bundesliga-based forward unmarked at the back post to convert.
Mahrez, these days playing for Saudi side Al-Ahli, then doubled the lead 12 minutes later with Amoura scoring his second, again from an assist from the former Premier League star in the 57th minute.
The fixture was a home game for Somalia, but because they do not have a suitable venue for international matches, it was hosted in Oran, handing the hosts Algeria the chance to celebrate qualification in front of a packed house at Stade Miloud Hadefi.