You can use a variable outside of the loop to keep track of something incrementing. You also weren't properly getting the right p tag in your loop, if I'm understanding you correctly.
var myObj = {
"dog":"pony",
"sass":"tude",
"war":"peace"
};
var lastMargin = 0;
for (i in myObj) {
$('#mainDiv').append("<p class='"+i+"'>" + i + "</p>");
lastMargin += 5;
$("."+i).css("marginLeft",lastMargin+"px");
}
You obviously might want to use :nth-child with the i variable instead of classes.