US department store chain JC Penney has swung to a second quarter loss after taking a combined hit from lower sales and pension plan costs.