OfficeMax swung to a fourth-quarter profit as the company retailer continued to cut costs, though sales declined in both its contract and retail segments.