I had the same problem with my 05 F 250 that started about 50 miles after I picked it up.
Was told it was a "shifting solonoid " inside the tranny. They had to drop the pan to get to it, but it was a simple fix.
It was covered under warranty so I can't tell you what it would have cost.