Shakespeare’s main sources for Julius Caesar were Plutarch’s biographies of Julius Caesar and Marcus Brutus, which he read in the 1579 English translation of Thomas North. The episode you are asking about appears in the biography of Brutus:
His wife Porcia (as we have told you before) was the daughter of Cato, whom Brutus married being his cousin, not a maiden, but a young widow after the death of her first husband Bibulus, by whom she had also a young son called Bibulus, who afterwards wrote a book of the acts and gests¹ of Brutus, extant at this present day. This young lady, being excellently well seen² in philosophy, loving her husband well, and being of a noble courage, as she was also wise: because she would not ask her husband what he ailed before she had made some proof by³ her self: she took a little razor, such as barbers occupy⁴ to pare men’s nails, and, causing her maids and women to go out of her chamber, gave herself a great gash withal in her thigh, that she was straight all of a gore blood⁵: and incontinently⁶ after, a vehement fever took her, by reason of the pain of her wound. Then perceiving her husband was marvellously out of quiet, and that he could take no rest, even in her greatest pain of all she spake in this sort unto him: “I being, O Brutus,” said she “the daughter of Cato, was married unto thee; not to be thy bed-fellow and companion in bed and at board only, like a harlot, but to be partaker also with thee of thy good and evil fortune. Now for thyself, I can find no cause of fault in thee touching our match: but for my part, how may I shew my duty towards thee and how much I would do for thy sake, if I cannot constantly⁷ bear a secret mischance or grief with thee, which requireth secrecy and fidelity? I confess that a woman’s wit commonly is too weak to keep a secret safely: but yet, Brutus, good education and the company of virtuous men have some power to reform the defect of nature. And for myself, I have this benefit moreover, that I am the daughter of Cato, and wife of Brutus. This notwithstanding, I did not trust to any of these things before, until that now I have found by experience that no pain or grief whatsoever can overcome me.” With those words she shewed him her wound on her thigh, and told him what she had done to prove herself. Brutus was amazed to hear what she said unto him, and lifting up his hands to heaven, he besought the gods to give him the grace he might bring his enterprise to so good pass⁸, that he might be found a husband worthy of so noble a wife as Porcia: so he then did comfort her the best he could.
¹deeds; ²well versed; ³of; ⁴use; ⁵covered in blood; ⁶immediately; ⁷with constancy; ⁸success.
Plutarch (c. 100). ‘Life of Marcus Brutus’. Translated by Thomas North (1579). In Walter Skeat, ed. (1875), Shakespeare’s Plutarch, p. 115. London: Macmillan.
This is quite clear about Portia’s motivations: in order to demonstrate to her husband in the most dramatic fashion that she has the fortitude to endure pain, and the constancy to keep secrets, she has cut herself and hidden the wound from her husband.
Plutarch’s original Greek is ‘μηρός’ meaning ‘thigh’ or ‘thigh-bone’. The word appears in the Iliad I.190 where Achilles wonders whether to ‘draw his sharp sword from beside his thigh’ (‘φάσγανον ὀξὺ ἐρυσσάμενος παρὰ μηροῦ’).
You’ll see that Shakespeare follows North’s translation of Plutarch very closely at some points in the scene. In this extract I’ve bolded parts of Shakespeare’s text that particularly resemble passages in North:
PORTIA. I should not need, if you were gentle Brutus.
Within the bond of marriage, tell me, Brutus,
Is it excepted I should know no secrets
That appertain to you? Am I yourself
But, as it were, in sort or limitation,
To keep with you at meals, comfort your bed,
And talk to you sometimes? Dwell I but in the suburbs
Of your good pleasure? If it be no more,
Portia is Brutus’ harlot, not his wife.
BRUTUS. You are my true and honorable wife,
As dear to me as are the ruddy drops
That visit my sad heart.
PORTIA. If this were true, then should I know this secret.
I grant I am a woman, but withal
A woman that Lord Brutus took to wife.
I grant I am a woman, but withal
A woman well reputed, Cato’s daughter.
Think you I am no stronger than my sex,
Being so father’d and so husbanded?
Tell me your counsels, I will not disclose ’em.
I have made strong proof of my constancy,
Giving myself a voluntary wound
Here in the thigh. Can I bear that with patience
And not my husband’s secrets?
BRUTUS. O ye gods,
Render me worthy of this noble wife!
William Shakespeare (1599). Julius Caesar, act II, scene I.
The question wonders (if I interpret it correctly) whether ‘thigh’ has a sexual connotation. I think that there is a choice of interpretations here. The plain reading of the passage is that Portia is demonstrating her bravery and constancy, and the cut is in the thigh because this is the best place to keep the wound secret, as it will be hidden by clothing. But we also recognise that deliberate self-injury can be a response to an intolerable situation, when one’s words and concerns are being ignored, as Portia’s are by Brutus. It is in this second interpretation that ‘thigh’ might have a sexual significance: a part of the body that ought, in a healthy marriage, to be a site of sexual pleasure, becomes, in Portia and Brutus’s marriage, a target of secret violence.
This last interpretation seems to have influenced Elisabetta Sirani’s 1664 painting of the episode:

(Image from Wikimedia Commons.)