ANSWER: In order to answer your question we need to look at the context of the different statements. We pick up the story as Paul states to the council that he has lived his life so far with a clear conscience. The High Priest at the time, Ananias, orders someone standing near Paul to slap him in the face (maybe because they thought he was lying?). Paul's response, to say the least, is immediate and blunt.
'God will certainly strike you - you whitewashed (whited) wall! . . .' 4 The men close to Paul said to him, 'You are insulting God’s High Priest!' 5 Paul answered, 'My fellow Israelites, I did not know that he (Ananias, who served as High Priest from about 46 to 52 A.D.) was the High Priest. The scripture says, 'You must not speak evil of the ruler of your people.'' (Acts 23:3 - 5)
The reason Paul repented is that part of what he said to the high priest was against the law. But it was not the part about calling the high priest a "whited wall" or "whitewashed wall" that was wrong; it was instead Paul's asking God to smite or strike the high priest. That was the "curse" against a leader that he repented of.
The commandment not to curse "the ruler" of the Israelites was a part of the Old Covenant (Exodus 22:28).
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).
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" (Matthew 23:25-28).
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. Yes, Paul did curse the high priest, but it was asking God to condemn him that was the problem.