He was part of Thor's vision quest
Tom Hiddleston discussed this in a 2015 interview with Digital Spy:
Hiddleston: I was part of the dream sequence for the character of Thor, and I show up for a day, and enjoyed it very much, and then I received a phone call from Kevin Feige [something about getting an email from Joss Whedon that I can't decipher], but basically Kevin said - and I'm just going to tell you the truth because it's the cleanest way of doing it - that in test screenings, audiences had sort of over-emphasized Loki's role so they thought that because I was in it that was controlling Ultron, and that it was actually imbalancing people's expectations. So Joss and Kevin were like 'We've got to...let's cut it because it's confusing people'
Joss Whedon gave more details in a 2015 appearance on the Empire Podcast, saying that the scene included Hiddleston doing his best impersonation of Anthony Hopkins (who plays Odin):
We even had a little reference to the fact that he’s taken the throne, which was Tom doing his Anthony Hopkins impression when Thor says, 'Oh, what would father say?' Then Tom does his Hopkins impression, and Thor’s like, 'That is uncanny!' It’s sort of like his subconscious is telling him that Loki was imitating his father.
As far as I know this scene has never been made publicly available; the special edition Blu-Ray (which I don't have, because format wars are dumb) did contain a number of deleted scenes, but apparently didn't have this one.