What contemporary readers may not understand is Paul's reference to the high priest as a "whited wall". In the time of Paul indoor plumbing was quite scarce and there were in the cities designated areas where the public could urinate. Usually these incorporated a wall with a drain at its base that would allow the urine to drain to an appropriate area and the wall itself diminished the splashing that often occurs when urinating. In order to minimize the smell these walls were "dusted" (the Hebrew word koniao translated as "whitened" actually refers to spreading lime dust, which is still used in outdoor toilets in many areas) or "whited" or "whitewashed".
While referring to someone as a wall upon which the public urinated could be considered vulgar, it was not a "curse".
Paul reacted in pain and anger to his being struck. As a student of the law he knew that the law forbade punishing anyone before their guilt had been established in the testimony of two or more witnesses. Yet that did not excuse his cursing the man – even though Paul did not know that he was the high priest (Acts 23:5).
"And those who stood by (by the apostle Paul) said, 'Do you revile God's high priest?' Then Paul said, 'I did not know, brethren, that he was the high priest; for it is written, 'You shall not speak evil of a ruler of your people.' ' " (Acts 23:4-5, NKJV)
Jesus' comments were not made to the "ruler of the people" but to the Pharisees. Furthermore, He pronounced no curse of any kind. He was calling their hypocrisy to account and used the analogy of "whited sepulchers" or "whitewashed tombs".
Here is Jesus' statement in context, again in two translations:
"Woe unto you, scribes and Pharisees, hypocrites! For ye make clean the outside of the cup and of the platter, but within they are full of extortion and excess. Thou blind Pharisee, cleanse first that which is within the cup and platter, that the outside of them may be clean also.
"Woe unto you, scribes and Pharisees, hypocrites! For ye are like unto whited sepulchers, which indeed appear beautiful outward, but are within full of dead men's bones, and of all uncleanness. Even so ye also outwardly appear righteous unto men, but within ye are full of hypocrisy and iniquity." (Matthew 23:25-28, KJV)
"Woe to you, teachers of the law and Pharisees, you hypocrites! You clean the outside of the cup and dish, but inside they are full of greed and self-indulgence. Blind Pharisee! First clean the inside of the cup and dish, and then the outside also will be clean.
"Woe to you, teachers of the law and Pharisees, you hypocrites! You are like whitewashed tombs, which look beautiful on the outside but on the inside are full of dead men's bones and everything unclean. In the same way, on the outside you appear to people as righteous but on the inside you are full of hypocrisy and wickedness." (Matthew 23:25-28, NIV)
The only connection between Jesus' statement and Paul's is the use of the term "whited" or "whitewashed". Jesus was speaking of tombs, which were often dusted with lime (whitewashed) for the same basic purpose as with Paul's "wall" – to cover or hold down the smell. Furthermore, Jesus was not calling the Pharisees whitewashed tombs but saying they were "like" whitewashed tombs.
Jesus used a perfect analogy to describe the hypocrisy of the Pharisees and explained the analogy to them without cursing them in any respect.
By digging a little deeper we have found no contradiction between Jesus' and Paul's statements mentioned in your question.