I think in general if you bring it, its for the host. But there are exceptions. If this is a close friend and you are basically helping them out by bringing some booze, because they are unable to afford to host, almost like a liquor potluck thing, its ok. I do definitely think it should be said as you arrive though, to avoid awkwardness later.
When I was young - 21 or 22 ish - a very close friend got her first apartment and was planning a party. She was young and poor; we all were. She asked me to bring cosmo makings. Well that's like $40+ of ingredients (vodka & triple sec, plus lime juice & cranberry). I did, as well as some snack food. At the end of the night there was almost no vodka or cran left, but plenty of triple sec and lime. I went to take those 2 back. She called me out as rude. I was mortified, and ticked. It wasn't a hostess gift, it was me helping her throw the party she wanted, at her request, and it was expensive. I took it anyway, but over 15 years later I still remember the incident annoyingly.