From what I've investigated around this topic, the answer above is slightly off, but the true answer isn't known because the backstories set up in the books do somewhat conflict with the events laid out in the film.
In the books, Jack works for Cutler Beckett after being banished from the pirate community after helping some convicted rogue pirates (who broke The Code) escape (he thought they were innocent, but they weren't and kidnap and indenture Jack for a while on their ship). Beckett originally wants him to ship slaves, but Jack refuses, so Beckett offers him an old ship he owns personally and wouldn't be good to retrofit for slave holding (the Wicked Wench). How Beckett comes by the Wench is unclear, and in the books, it is a very-clearly East India Trading ship, painted gold, unlike the ship seen in DMTNT.
Jack jumps at the chance to be on a ship not oriented around slavery (in the books, he hasn't been a boy on the ship as happens in the film, explicitly), and is tasked with discovering a long-lost island, but once he does, (with the help of a princess... long story), he refuses to tell Beckett the location because he knows Beckett will turn the island's population into slaves.
Beckett gets super mad and forces him to put some slaves in the Wicked Wench and transport them, but Jack takes them back to that long-lost island he found, who agree to take in the slaves as refugees. Beckett, once he realizes, sends a bunch of ships after Jack, captures him, and basically makes him watch as he burns the Wicked Wench. Jack escapes the guys holding him and swims to the Wench, trying to save her, but is dragged down with the wreckage, at which point he encounters Davy Jones and makes the deal to resurrect the ship as the Black Pearl and command it for 13 years.
So, how does this all tie in with the last film? There's no definitive answer, only potentially workable solutions. Clearly, the Wench portrayed in DMTNT is a pirate ship — it's colored like one, has a pirate crew, and Salazar is after them. The events of this scene take place before Jack's ousting from the Brethren Court, and in between, it is known that Jack returns to Shipwreck Cove and goes on some adventures with Teague (his father) on the Troubador. This begs the question of what happens to the Wench in this time, which, because we are at the discontinuity between the films and books (which don't include the flashback scene we see in DMTNT), leaves us empty handed. It's possible Jack voluntarily gives control of the ship to someone else, or has it mutinied from him, or he sells it, leaving him free to join Teague. Then the business with the rogue pirates happens, then Jack is forced to work for the EITC. He proves himself valiant on the Fair Wind, Beckett offers him the slave ship, he says no, and Beckett brings up the Wench.
So presumably, in the intervening time, Beckett has bought and re-painted the Wench as a EITC vessel. Does Jack indicate he's been on this ship in the past? We have no idea. Anyways, that's one possible workaround, but there is no /fully/ canon answer to the question.
Source(s): http://pirates.wikia.com/wiki/Jack_Sparrow and associated pages.