How do detect if a layer is an output layer?

Typically I use

for name, module in self.model.named_children():
    # do stuff here with layers

to iterate through my model to modify layers. Is there a way where I can detect if the current module is the last in my network, so that I can treat this layer differently?

The proper way would be to check the forward method of your model, as it would define which layer is used last.
Since you could use arbitrary conditions inside the forward, you would have to check the actual logic.
In case you are using an nn.Sequential module, you could directly use the last layer.