Judah only claimed she was a harlot because she was pregant and married to his son Er (Shelah? Wasn't Er dead by then?)
If you read the account you will see that Judah felt the unknown woman he had sex with was a temple prostitute. Later Tamar identified herself as that unknown woman.
38 And it came to pass at that time, that Judah went down from his brethren, and turned in to a certain Adullamite, whose name was Hirah.
2 And Judah saw there a daughter of a certain Canaanite whose name was Shua. And he took her, and went in unto her.
3 And she conceived, and bare a son; and he called his name Er.
4 And she conceived again, and bare a son; and she called his name Onan.
5 And she yet again bare a son, and called his name Shelah: and he was at Chezib, when she bare him.
6 And Judah took a wife for Er his first-born, and her name was Tamar.
7 And Er, Judah's first-born, was wicked in the sight of Jehovah. And Jehovah slew him.
8 And Judah said unto Onan, Go in unto thy brother's wife, and perform the duty of a husband's brother unto her, and raise up seed to thy brother.
9 And Onan knew that the seed would not be his; and it came to pass, when he went in unto his brother's wife, that he spilled it on the ground, lest he should give seed to his brother.
10 And the thing which he did was evil in the sight of Jehovah: and he slew him also.
11 Then said Judah to Tamar his daughter-in-law, Remain a widow in thy father's house, till Shelah my son be grown up; for he said, Lest he also die, like his brethren. And Tamar went and dwelt in her father's house.
12 And in process of time Shua's daughter, the wife of Judah, died; and Judah was comforted, and went up unto his sheep-shearers to Timnah, he and his friend Hirah the Adullamite.
13 And it was told Tamar, saying, Behold, thy father-in-law goeth up to Timnah to shear his sheep.
14 And she put off from her the garments of her widowhood, and covered herself with her veil, and wrapped herself, and sat in the gate of Enaim, which is by the way to Timnah; for she saw that Shelah was grown up, and she was not given unto him to wife.
15 When Judah saw her, he thought her to be a harlot; for she had covered her face.
16 And he turned unto her by the way, and said, Come, I pray thee, let me come in unto thee: for he knew not that she was his daughter-in-law. And she said, What wilt thou give me, that thou mayest come in unto me?
17 And he said, I will send thee a kid of the goats from the flock. And she said, Wilt thou give me a pledge, till thou send it?
18 And he said, What pledge shall I give thee? And she said, Thy signet and thy cord, and thy staff that is in thy hand. And he gave them to her, and came in unto her, and she conceived by him.
19 And she arose, and went away, and put off her veil from her, and put on the garments of her widowhood.
20 And Judah sent the kid of the goats by the hand of his friend the Adullamite, to receive the pledge from the woman's hand: but he found her not.
21 Then he asked the men of her place, saying, Where is the prostitute, that was at Enaim by the wayside? And they said, There hath been no prostitute here.
22 And he returned to Judah, and said, I have not found her; and also the men of the place said, There hath been no prostitute here.
23 And Judah said, Let her take it to her, lest we be put to shame: behold, I sent this kid, and thou hast not found her.
24 And it came to pass about three months after, that it was told Judah, saying, Tamar thy daughter-in-law hath played the harlot; and moreover, behold, she is with child by whoredom. And Judah said, Bring her forth, and let her be burnt.
25 When she was brought forth, she sent to her father-in-law, saying, By the man, whose these are, am I with child: and she said, Discern, I pray thee, whose are these, the signet, and the cords, and the staff.
26 And Judah acknowledged them, and said, She is more righteous than I; forasmuch as I gave her not to Shelah my son. And he knew her again no more.