Minecraft wiki entry for Before_1.8, associated text: Simultaneously renaming and repairing an object costs both charges, but you only pay for Base Value and the (current) penalty once. For example, consider an item with Base Value of 5 never renamed before, with two prior works (penalty of 4). Then this item is altered a third time, for a repair costing 3 (over Base+Penalty). Repairing and renaming it simultaneously would cost (5+4)+3+7=19, as opposed to 5+4+3=12 for a repair alone or 5+4+7=16 for a rename alone.
An item which has been renamed has its prior-work penalty set to 2, remaining so regardless of later work. Renaming the item back to its default name (e.g. "Iron Sword") does not revert prior-work to full cost.[note 1]
As a consequence of the above, and using the same example, if you then damage that item slightly so that the next (fourth) repair cost would be 3 levels (over BV+Penalty), the renamed item will cost (5+2)+3=10 levels to repair, while if the item was not renamed before it would cost (5+6)+3=14 levels (4 more).