The video card you pick up will depend on the physical dimensions of the case, and the wattage your power supply can deliver. The
GTX 1050Ti has a very small form factor, 4GB of memory, and only draws about 150 watts under extreme load. It isn't the newest card, but if you are looking for a basic video card to replace on board graphics this will be more than sufficient.
If your Optiplex is a larger tower, you could move up to an
RX 570, which will perform better than the GTX 1050Ti, and can often be found for less money. This card also draws around 150 watts of power, with a recommended PSU of 450 watts.
If you aren't married to exactly 4GB of memory, the
RX 580 can be found for less than 200 dollars, but this will come down to power supply constraints. Hope this helped, take care.