Paul often cites passages from the scriptures, as he does here. His intention is to encourage charity, as does the passage he is citing from Proverbs.
Rather, "if your enemy is hungry, feed him; if he is
thirsty, give him something to drink; for by so doing you will heap
burning coals upon his head." Do not be conquered by evil but conquer
evil with good.
If your enemy be hungry, give him food to eat, if
he be thirsty, give him to drink; For live coals you will heap on his
head, and the LORD will vindicate you.
The reference to "burning coals on his head" seems rather odd and to a modern reader implies quite the opposite to charity, instead the desire to inflict injury. This is explained by Kenneth Samuel Wuest here. In biblical times an oriental needed to keep the hearth fire going in order to provide warmth and for cooking. If it went out he had to go to a neighbour for some live coals, which he would carry on his head back to his home. If enough coals are heaped on his head, the man would be sure to get home while they were still burning. So, heaping coals on a man's head met a need just as feeding him and giving him drink did.
Another view is less charitable. It suggests taking revenge by showing love, causing the enemy to feel pangs of anguish, like the pain of fire, for having wronged you. But not only is this unworthy, it also does not explain the quite specific reference to coals on the head.
Sometimes Paul uses Old Testament passages out of context, but in this case both passages recommend charity.